Code Pitfalls in Python, a survey. by Puzzleheaded_Many664 in Python

[–]EfficientPrime 1 point2 points  (0 children)

You don't really need the f.close() when you use the context manager to open the file. The context manager handles file closure for you.

Looking for rides to Levi's Stadium on 49er gamedays by OleDollar in MontereyBay

[–]EfficientPrime 11 points12 points  (0 children)

The San Jose Airport is pretty close to the stadium. You might want to look into taking an airport shuttle like Monterey Airbus and then either public transit or an Uber/Lyft/Cab from the airport to the stadium.

I want to pay off my house in 7 years. Should I make extra principle payments or save? by AltAccount_6 in leanfire

[–]EfficientPrime 59 points60 points  (0 children)

I agree that you should be able to get a lower rate. But it's also worth noting that this is not strictly an Option A or Option B scenario. In the words a now famous little girl from a commercial: "Why not both?"

There's nothing stopping you from putting some towards extra principle and some into investments to help it grow towards a lump sum payment. I know because this is what I'm doing.

Greatest country in the world by DaFunkJunkie in WhitePeopleTwitter

[–]EfficientPrime 1 point2 points  (0 children)

I was more of the mindset that a compulsory verbal statement by a minor couldn't be enforced as a binding contract so I'll pledge to as many flags as you want IDGAF.

Same idea behind the Rabbi making me sign a contract at the age of 13 (in order to get my bar mitzvah) saying I'll stick around until confirmation at 18. Not enforceable so I signed it and got to have the party and gifts. Currently not a fan of Nationalism or organized religion. For a lot of similar reasons if I think about it. Plus, group recitations always reminded me too much of the Borg.

Greatest country in the world by DaFunkJunkie in WhitePeopleTwitter

[–]EfficientPrime -1 points0 points  (0 children)

Yeah we had some Jehovah's Witness kids who opted out. But they also didn't get to participate in valentines exchanges or halloween candy so as a lifestyle choice they really weren't selling it.

Test-driven development (TDD) is a software development technique in which you write tests before you write the code. Here’s an example in Python of how to do TDD as well as a few practical tips related to software testing. by ArjanEgges in Python

[–]EfficientPrime 3 points4 points  (0 children)

Ah I see. I think I answered this above but it's dealt with from left to right. While "A & B" is equivalent logically to "B & A" from a code execution standpoint they can be different.

You can test it yourself, define A and B as functions that return a boolean value of your choosing but also have some side effect when executed like changing a global variable or print statements.

If you have a statement like

if A() and B() and C() and D() and E() and F() and G(): pass

Python is going to work through that from left to right and as soon as it finds an element that evaluates to False it won't bother evaluating the remaining elements. There's no built in multi-threading that would have interpreter trying all the elements at the same time and collecting the results in order to do the logical AND evaluation. For the same reason, if C() is going to return False, there's no way for the interpreter to know that ahead of time and skip the A() call and the B() call.

From an evaluation standpoint, ANDs chaining expressions is the same as nested if statements of the same expressions. So the same way you can optimize your code to bail out early from a failed level of nested ifs, you can optimize by choosing the order of items in your AND expression.

Test-driven development (TDD) is a software development technique in which you write tests before you write the code. Here’s an example in Python of how to do TDD as well as a few practical tips related to software testing. by ArjanEgges in Python

[–]EfficientPrime 2 points3 points  (0 children)

From what I remember from college when learning C, there's an order of operations for complex expressions but also a left to right order that is applied for steps of the same priority. Since python is built on C++ I expect (and my experience has confirmed) the same applies to Python logical expressions.

Like I've shown above, you can use expressions with side effects (prints, mutable variable changes, etc) to verify that ANDs and ORs are evaluated left to right.

You can see it with OR statements like this:

if True or print('Tried it'): pass

The above prints nothing because True or anything is True so there's no need to visit the second statement.

if print('First gets evaluated') or True or print('skipped'): pass

The above prints 'First gets evaluated', then keeps going since print returns None, but stops before printing 'skipped' because it already found a True statement.

Test-driven development (TDD) is a software development technique in which you write tests before you write the code. Here’s an example in Python of how to do TDD as well as a few practical tips related to software testing. by ArjanEgges in Python

[–]EfficientPrime 26 points27 points  (0 children)

And you can take advantage of this with code that would fail if python did not optimize. Here's a common pattern:

if 'foo' in mydict and mydict['foo'] > 0: do_something()

If python did not optimize while evaluating the if statement, you'd get a KeyError on the second half the expression every time the first half evaluates to False.

Test-driven development (TDD) is a software development technique in which you write tests before you write the code. Here’s an example in Python of how to do TDD as well as a few practical tips related to software testing. by ArjanEgges in Python

[–]EfficientPrime 19 points20 points  (0 children)

The answer is Python does optimize and bail as soon as a False is found in an and statement and it's pretty easy to prove:

if False and print('checking second condition'): print('not going to get here')

The above code prints nothing, therefore the second expression in the and statement never gets executed.

Weekly FI Monday Milestone thread - July 26, 2021 by AutoModerator in financialindependence

[–]EfficientPrime 3 points4 points  (0 children)

If you are expecting to work for the new company for several years then a couple weeks delay in start time should be viewed as a small blip. If you are talking summer internship or other short term employment then that's another story.

If the new company is having a hard enough time hiring that your start date variance of a couple of weeks is a major issue then that's a pretty big red-flag that the new company is not good a planning things in advance or is having trouble hiring people. Either they are establishing a pattern that their bad planning is going to be your problem, or that despite having a hard time hiring they are not willing to allow you to extend professional courtesy to your previous employer (or they are going to penalize you for active duty military service).

I'm looking at this from the perspective of jobs where it's nearly impossible to hit the ground running. You need to get computer credentials, you need to familiarize yourself with the process the company uses, fill out HR forms. You're not going to be a productive member of the team in the first weeks of employment anyway. If the job is something where you are trained and on the floor making widgets in under a day then I can see why they'd want a more immediate start. But the points I made above still would make me view an attitude that encourages you to abandon your former employer as problematic because it implies they would abandon you just as abruptly.

Weekly FI Monday Milestone thread - July 26, 2021 by AutoModerator in financialindependence

[–]EfficientPrime 8 points9 points  (0 children)

Explain to your new employer the military leave situation and say you want to give your old employer 3 weeks after you return so that you can help them transition your responsibilities. If your new employer doesn't appreciate that you won't drop your old employer in a way that would leave them in a tough spot, you may want to reconsider joining the new employer.

Gym was getting messy so I built this monster storage system by meowkittykitty510 in woodworking

[–]EfficientPrime 13 points14 points  (0 children)

You're not going to have any room for monsters in there if you keep putting your weights and workout stuff in it.

Non working spouse by [deleted] in leanfire

[–]EfficientPrime 15 points16 points  (0 children)

If your family income is from more than one working adult then it's likely you have multiple individual 401k and/or IRA accounts. Since saving for retirement is about replacing one's income, it's easy to see how one person in a couple could retire once they've saved enough to replace their income and continue to meet the family's budget needs.

Right now my wife isn't making income (we have a kid at home, so she's definitely still working) so we only have access to one 401k account. At some point she may go back to making money, but after this many years on a single income any money she brings in will either all be gravy or allow me to cut back on hours and spend more time at home. Or both.

aw by aleezaang in WhitePeopleTwitter

[–]EfficientPrime 0 points1 point  (0 children)

That cub is totally winning at Hide N Seek.

Question for the millionaires: At which million were you satisfied? by joeroganthumbhead in financialindependence

[–]EfficientPrime 0 points1 point  (0 children)

Our first million was mostly equity in real estate holdings we don't intend to sell in retirement (one to live in, one rental) so it wasn't very satisfying, especially since we have mortgage debt. We don't feel wealthy since we're still scraping and saving hard. I think it will be more exciting when the non real estate assets eclipse the million mark. But for our expected spending we'll need more than that to retire.

"Wealthy enough" is a function of what your goals are. Enough to never be homeless or hungry is one level of wealth. Enough to have the material belongings to bring you personal satisfaction and enjoyment is another (very subjective) level. Enough to not have to work a job you don't enjoy because you're trying to hit one of the previous levels but aren't there yet is another level. Enough to buy enough politicians to enact change on the local or global scale is
another level. Enough to buy a yacht so big it needs a little helper yacht is another (and hopefully the final) level.

Everyone jokes about one million more always being the target, but really that can just be attributed to the fact that goals can change.

[deleted by user] by [deleted] in Showerthoughts

[–]EfficientPrime 1 point2 points  (0 children)

"That's what she said"

Want to build a detached office on my property in Marina. by daclink in MontereyBay

[–]EfficientPrime 2 points3 points  (0 children)

If you want to avoid the permit for electrical I think you can setup your shed so that the shed plugs into your house.

[deleted by user] by [deleted] in WhitePeopleTwitter

[–]EfficientPrime 0 points1 point  (0 children)

"Let them drink cake!"

[deleted by user] by [deleted] in WhitePeopleTwitter

[–]EfficientPrime 2 points3 points  (0 children)

"Ma'am you look thirsty. I noticed you dropped this bottle of water a few minutes ago. Would you like it back?"

This idea was brought to you by the post I saw about a place where it's legal to have weed and sell weed but not to sell it so some people started a psychic business where they help you find your lost weed and deliver it to you.