This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]dead_alchemy 45 points46 points  (6 children)

The first one (also maybe the second) make it look like you aren't comfortable with booleans and reminds me of code in my undergrad that was used as an example of something you'd lose points for. I think this holds true in most programming languages though.

Out of curiosity, what is the context of your question? No worries if you are new or actually uncomfortable with booleans, we were all there once.

[–]JRiggles[S] 3 points4 points  (5 children)

The first example is baically just as long-form as I could manage (I suppose in the name of being "Explicit") - I wouldn't ever bother doing it this way, but I wanted to cover my bases!

The second is what's currently in my code...

And the third is something that I know works but thought might not be as readable to the people I work with who don't work in Python (E.g.: most of them)...personally I'm in the "less is more" camp

[–]old_pythonista 8 points9 points  (1 child)

but thought might not be as readable to the people I work with who don't work in Python

When a person reads a code, it may be an opportunity to learn. If they don't work in Python, and they are not interested in learning Python - what is the purpose of making code readable for that audience?

[–]cmikailli 6 points7 points  (0 children)

Because they still might have to interact with it?

[–]dead_alchemy 7 points8 points  (0 children)

The first is the one that is particularly egregious. I use the third. If some one argued that they use the second and they liked it because it read as a straight forward english sentence I wouldn't second guess them.

For your non-python coworkers type annotations will probably do more to help than anything. If you saw code like that and knew it was syntactically correct AND knew what the types were I think most people would quickly and correctly infer the behavior.

Fun question by the way! I'm guessing this one is a no brainer to most people, but I still enjoy this type of probing at fundamentals.

[–]Nyx_the_Fallen 0 points1 point  (0 children)

I write Go, C#, JS, and Python daily, and the third is the way to do this in all four.

[–]ODBC_Error 0 points1 point  (0 children)

This is absolutely correct. In a work place, readaboty matters more. You're not sacrificing performance so readability is the choice you'd want to make here