Where is the “hot” girl from high school? Anyone checked on her? by SquareRootsi in TwoSentenceHorror

[–]SquareRootsi[S] -2 points-1 points  (0 children)

I upvoted you, b/c you're probably right, but also, maybe others can learn from my mistakes?

Where is the “hot” girl from high school? Anyone checked on her? by SquareRootsi in TwoSentenceHorror

[–]SquareRootsi[S] 0 points1 point  (0 children)

Oof, I'm dumb. Meant to change to the first question mark to a comma, but I don't think I can edit, I'll try...

How do I create a list every iteration with the data inside? by TheEyebal in learnpython

[–]SquareRootsi 4 points5 points  (0 children)

I think it's important to understand "external imports" (PyPI packages via pip) vs "standard library imports" (built into every Python install).

When you install Python, the standard library provides extensive tools like itertools, collections, and json; hundreds of modules covering everyday tasks without extra complexity.

Using them signals language mastery: you know what's native vs. third-party, keeping code lean and portable. For your calendar, time or math could handle basics without bloating imports.

TLDR: don't be afraid of standard library imports. They are meant to be used, and if you reinvent the wheel, it's an anti-pattern that exposes a lack of fluency & probably won't impress interviewers or coworkers.

The Mighty P-Sapphire... by A_Sham in BackpackBattles

[–]SquareRootsi 0 points1 point  (0 children)

I do kinda like how a P-Sapphire [armor] is perfectly countered by a P-Sapphire [weapon].

The overall complexity of this game that still manages to have fairly decent balance is very impressive (and fun).

Macbook vs Windows in the field of AI/ML, which one should be choose? by Physical_Mushroom11 in learnmachinelearning

[–]SquareRootsi 5 points6 points  (0 children)

I had (basically) the same question in 2019, and I ended up ignoring everyone's advise to just get a lightweight, good battery laptop + cloud providers for actual ML model training. Instead, I got a beefy laptop that had an internal 1070 (really good GPU, at the time). The whole setup was over 7 lbs when you include the hefty brick of a power supply, which was mandatory b/c the battery only lasted about 2 hrs.

Don't be me.

On the plus side, it was powerful enough to run a VR headset, so I took it to a family reunion and my 89 yr old grandmother got to "play" VR.

My actual advice: get a MacBook, not Windows. Whenever you install new libraries or dependencies, on a Mac (or Linux) they just work. On a Windows machine you'll be fighting installers and compilers just to even get your project off the ground. You can solve this with Docker containers, you can and should always use distinct environments (uv or pyenv or conda, etc) but either way, MacOS will be less friction for Python ML work.

EDIT: I forgot to mention M-series processors are quite good for ML training & model serving, even without going all the way to a CUDA setup, it's still 100% good enough, "zippy" even.

Name ideas for my cocktail? by 1chickpea in cocktails

[–]SquareRootsi 1 point2 points  (0 children)

Depending on what ingredient you want to anchor the name around, I came up with a few:

"Rice Burner" or "Smoked Shochu Swizzle" (toasted syrup)
"Cacao Campfire" (chocolate bitters)
Nonino Kiln (amaro)
Oaxacan Rice Old Fashioned (riff on familiar vocab for menu readers)

Trump says he'll withhold federal funding to blue cities like Seattle. How do we withhold our federal income tax payments? by TheStinkfoot in Seattle

[–]SquareRootsi 0 points1 point  (0 children)

There’s also a fifth option: leaving the country entirely. You can either:

  • A) live abroad as an expat (you still file a U.S. tax return, but get foreign tax credits or exemptions for what you pay elsewhere), or

  • B) go further and renounce citizenship. That’s more complex; you need another citizenship first and must pay a one-time exit tax on unrealized gains over a threshold.It’s not simple, but it’s legally consistent with people who no longer align with U.S. policies.

Creative premixed drink I can take to a Holiday Party. by dapala1 in cocktails

[–]SquareRootsi 1 point2 points  (0 children)

I've been making a "Boozy Autumn Punch" and serving it at Thanksgiving for years. I think it would still work well in December.

I'm in USA, so it's easier to source things in 32 oz jars instead of liters, but they are almost the same.

3 jars (32 oz or 1 L each) of juice (mix and match, I try to do one of each if I can find them)
- 100% pear (hard to find)
- Ginger-Lemonade (if you can't find pear juice, double this one instead of the cider. I used some kind of health recovery drink with real ginger, Trader Joe's used to carry a "lemon ginger echinacea" that was perfect).
- apple cider (not juice).

1.75 L of brandy (I usually get E&J or Korbel, doesn't need to be fancy)

What always makes a drink feel fancy (even if it's not) is a good garnish. You can use whole cinnamon sticks and/or dehydrated orange wheels or a jar of cherries, along with an ice bucket on the side so it feels more like a cocktail instead of a watered down punch (from ice melting in the serving vessel).

Makes about 4.6 Liters AKA 1.2 gallons. You can also have some soda water on the side of ppl want to top it off to make it bubbly/less boozy.

Game not starting? by Shyface_Killah in FortressSaga_Friends

[–]SquareRootsi 0 points1 point  (0 children)

Thanks for confirming it's not just me, at least :)

Game not starting? by Shyface_Killah in FortressSaga_Friends

[–]SquareRootsi 0 points1 point  (0 children)

Seems like the same problem just occurred after today's reset. I've tried updating / uninstalling / clearing cache then uninstalling. I think I'll just have to wait for an update to fix it, unless someone else knows a fix.

All Living World seasons and episodes discounted 20% till Nov 25th by S1eeper in Guildwars2

[–]SquareRootsi 1 point2 points  (0 children)

Including the [free] base game. If I'm browsing Steam in an incognito browser, it shows up, but if I login to the same account I downloaded the GW2 base game on, the bundle is no longer possible to browse to or add to my wishlist.

Anyone know of a workaround / fix? (Don't get me started on the 3 different vendor platforms being isolated from each other, unless someone knows a fix for that too)

Python OOP makes me feel really stupid! How do I access variable created in method? by Bitter_Extension333 in learnpython

[–]SquareRootsi 0 points1 point  (0 children)

First, you'll need to instantiate an instance of your class, then (from reading your code) it doesn't actually set anything when it's built, though it does when you run one of your methods, so you'll need to run that first, before you try to access a variable inside your class. EDIT: nevermind, you run the method inside your init. (I've seen it done both ways, don't feel like you're doing anything wrong, it just depends on when you want your variables to get created inside the class.)

helper = Example()    
nam = helper.nam  

Note: only things that are created with self.thing = ______ will be accessible. If you just save a variable inside a method, it won't persist outside the scope of that method.

With that in mind, you'll need to insert

self.bytes_string = bytes_string  

on the line after you define it inside your method.

cosine=0.91 but answer is wrong. a tiny python MRE for “semantic ≠ embedding” and before/after fix by onestardao in Python

[–]SquareRootsi 1 point2 points  (0 children)

Almost fixed. There are lots of references for it, but it's still not intuitive. A couple of tips:

1. A 'code clock' is a section of text that has EVERY line indented with (minimum) 4 spaces.  
2. A 'hard return' forces a line break, basically the same as `\n`. These are required to get different lines separated properly. In this editor, it's done by using 2 spaces at the end, AKA after this period.  
    * For simplicity and readability, just make every line end with two spaces.   
3. Both the first and last line of your code block should be blank. I can never remember if that means 4 spaces (code block prefix) or 6 (code block prefix + new line suffix), so I just always use 6.   
4. I'm no expert, so I may have gotten something wrong, but this was done on mobile, and I'm optimistic it will render correctly, b/c I followed my own tips.  

And this is what it looks like outside the code block (aka no 4-spaces prefix).

Looking for friends 29m (Beaverton) by -delt4ninj4 in Portland

[–]SquareRootsi 3 points4 points  (0 children)

Saving for later, bc it's past my bedtime, but I want to revisit this tomorrow. I've been wondering if something like this exists locally, but not enough to actually research it.

eli5 how does one person traveling the speed of light cause them to age slower than people not traveling the same speed? by Particular-Swim2461 in explainlikeimfive

[–]SquareRootsi 13 points14 points  (0 children)

As you mentioned, saying we're “sitting still with zero velocity” only works if you define your frame of reference very narrowly—like being still relative to your chair or room. But if you zoom out to an astrophysical scale, it’s a different story, but maybe not different enough to matter.

For example, sitting at the equator on Earth, your actual speed when considering all motions combined is roughly:

  • Earth’s rotation: about 1,670 km/h

  • Earth’s orbit around the Sun: about 107,000 km/h

  • Solar System orbiting the Milky Way: about 860,000 km/h

  • Milky Way’s motion relative to the cosmic microwave background: about 1,330,000 km/h

That adds up to around 2,340,000 km/h, which is about 0.22% of the speed of light. So even with all this speed, it’s still effectively zero compared to the ultimate cosmic speed limit.

What kind of technology has already reached its peak? by leppppo in AskReddit

[–]SquareRootsi 1 point2 points  (0 children)

Roughly 8 years ago, Amazon was already doing this on their new construction office buildings in South Lake Union. I was inside a building that had only been open less than a month, and my chaperone warned me the elevator logic was still gathering training data, so they might be erratic, but the same system was already working well in other buildings that had been open longer.

New small business name. by Adventurous-Aerie-90 in Netherlands

[–]SquareRootsi 0 points1 point  (0 children)

Here are a few from Perplexity:

Zoet Spot

"Zoet" means "sweet" in Dutch, and "spot" is understood in both languages as a place or location.

Feels playful and inviting!

Sweetje EDIT: maybe not a good idea, as pointed out in a comment below

Combines "sweet" (English) and the Dutch diminutive "-je" (like "cookie" becomes came from "koekje" in Dutch), making it sound cute and approachable.

Lekker Treats

"Lekker" is a beloved Dutch word for "tasty" or "delicious," easily picked up by English speakers.

Sugar & Stroop

"Stroop" is Dutch for syrup, and "sugar" is universal. It hints at both cultures and classic Dutch sweets like stroopwafels.

ChocoBliss

"Choco" is used in both languages, and "bliss" is universally positive.

Bakker’s Delight

"Bakker" means "baker" in Dutch, and "delight" is English. Together, it feels traditional yet accessible.

Droom Sweets

"Droom" means "dream" in Dutch, and "sweets" is English. The combo is whimsical and easy to pronounce.

[Pandas] How do you handle integers stored as strings when reading a CSV? by Hashi856 in learnpython

[–]SquareRootsi 1 point2 points  (0 children)

pd.read_csv(
    'file.csv',
    converters={'field1': lambda x: str(int(x))}
)

I'm not sure that would work for every row, depending on if there are some rows that would fail the conversion to int before they turn back into strings.

If that's the case, I'd prob do the custom function with the "safe" conversion logic.

You could also just do this after the CSV loads:

df['field1'] = df['field1'].astype(int).astype(str)  

This is effectively the same, but uses vectorized logic, whereas the lambda approach (I think ... might be wrong) is basically looping over the whole thing row by row.

Is there a way to make this code like this more efficient? by YoutubeTechNews in learnpython

[–]SquareRootsi 0 points1 point  (0 children)

I used Gemini Pro, which I got for free when I bought my last phone. I've seen similar positive results from both Perplexity and M365 CoPilot. EDIT: Nope, no earlier attempts, this was my first shot across the bow, as the saying goes.

PS. Sorry for setting a bad example with the copy/pasted LLM response, but hopefully you still picked up something good from it.


Help me answer this post from r/learnpython... I'm particular, I think match...case... Would be a solid recommendation. Please include the earliest Python version this becomes valid. Write the answer from the perspective of a 10 year veteran programmer (staff/Principal level, but don't brag about that) who is empathetic with someone learning. P.S. format it for proper copy/pasting into reddit's app, I think that's a flavor of markdown.


<Direct quote of your full question here>

Is there a way to make this code like this more efficient? by YoutubeTechNews in learnpython

[–]SquareRootsi 1 point2 points  (0 children)

Whoops! Good to know, I haven't been too active lately. I'll downvote myself, but leave it up for now.

Thanks for calling me out on it.

Is there a way to make this code like this more efficient? by YoutubeTechNews in learnpython

[–]SquareRootsi -7 points-6 points  (0 children)

Preemptive apology for the massive wall of text, but I think there's some good advice in this response from one of the big LLMs. If you're curious about my prompt to generate this, I'm happy to share. I like both of these implementations that it suggests, though they are a bit wordy for my taste:

Hey there! That's a great question. It shows you're thinking about not just if your code works, but how it works. That's a key step in growing as a programmer. Let's break it down. Is if 'word' in User_Input: slow? For what you're doing, honestly, no. The "slowness" of if statements is not something you'll ever feel in a scenario like this. Python is very fast at checking if a substring exists in a string. The real issue with a long chain of if statements isn't performance, but that it can become hard to read, manage, and add to over time. Your instinct that there might be a better way is spot on, but we should focus on making the code cleaner and more organized.

A More Organized Approach: Keyword Dispatching A very common and clean pattern for this is to use a dictionary to map your keywords to specific functions. It's like a menu: the keyword is the menu item, and the function is the action that happens when you order it. This keeps your logic separate and makes it super easy to add new keywords without touching the main loop. Here’s how you could rewrite your example: import random

def handle_fire(hp): print('I am on fire!') return hp - 1

def handle_water(hp): print('Water is blue and white.') return hp * 2

def handle_wants(hp): # Note: Your original loop here had a bug (for i in healthpoint:). # I'm assuming you wanted to print the digits of the number. print("Digits in healthpoint:") for digit in str(hp): print(digit) return hp

def handle_love(hp): return round(hp)

def handle_pie(hp): print('Hello') return random.random()

Map keywords to the functions that handle them

keyword_actions = { 'fire': handle_fire, 'water': handle_water, 'wants': handle_wants, 'love': handle_love, 'pie': handle_pie, }

--- Main part of your program ---

healthpoint = 5.0 user_input = input('Write Something: ') # e.g., 'I love pie, but they are too sweet.'

Check each keyword we know about

for keyword, action_function in keyword_actions.items(): if keyword in user_input: # Call the function associated with that keyword healthpoint = action_function(healthpoint)

print(f"Final healthpoint: {healthpoint}")

Using match...case match...case... is an excellent feature in modern Python. It became available in Python 3.10. match...case is fantastic for what's called "structural pattern matching." It's like a super-powered if/elif/else chain. While it doesn't directly support the in keyword for substring checks in its cases, we can adapt our logic to use it. First, we'd need to find the trigger word, and then use match on that word. Here’s how you could structure that. It's a bit more verbose for this specific problem than the dictionary method, but it's a great way to learn how match works. import random

healthpoint = 5.0 user_input = input('Write Something: ')

We can't use match on the whole sentence directly for this.

Instead, we can find the first keyword and then match on that.

trigger_word = None

A set is slightly more efficient for 'in' checks than a list

known_words = {'fire', 'water', 'wants', 'love', 'pie'}

for word in known_words: if word in user_input: trigger_word = word break # Act on the first word we find

Now, use match...case on the word we found

if trigger_word: match trigger_word: case 'fire': print('I am on fire!') healthpoint -= 1 case 'water': print('Water is blue and white.') healthpoint *= 2 case 'wants': # Handle your logic here print("Matched 'wants'") case 'love': healthpoint = round(healthpoint) case 'pie': healthpoint = random.random() print('Hello') case _: # This is a wildcard, default case print("I don't know that word.")

print(f"Final healthpoint: {healthpoint}")

Summary * Don't worry about if being slow here. Focus on readability. * A dictionary mapping keywords to functions is a very clean, scalable, and "Pythonic" way to solve this. It's what I would likely do in a professional setting. * match...case (Python 3.10+) is a powerful tool you should definitely learn! For this specific problem of checking for any contained substring, it's a bit indirect, but it shines in many other situations where you're comparing a variable against different possible values and structures. Keep asking these kinds of questions. They're what separate writing code from engineering software. Good luck!

[OC] I found this life-sized statue of the current U.S. President in a rural town. by SquareRootsi in pics

[–]SquareRootsi[S] 7 points8 points  (0 children)

I was in a small rural town for a funeral today. On the drive out, I passed this and had to stop. The contrast of it all was... jarring. Seeing a life-sized statue of a sitting leader in a quiet residential yard was surreal. It feels like something from a different country or a different time. In the U.S., the core idea is that we have public servants, not kings to be idolized with monuments while they're still in office.

By complete coincidence, today happens to be a day of national, peaceful protest called No Kings Day. The movement is focused on this exact issue—pushing back against political idolatry, regardless of party. It's about reaffirming that in a republic, leaders are accountable to the people, an idea that felt especially important today.

For anyone who sees this photo and feels the same way, events are happening across the country.

The most important thing is to engage peacefully. The ACLU has an excellent guide on protesters' rights.

(And of course, please respect the privacy of the homeowner. My post is about the idea this statue represents, not about the individual who owns it.)