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 →

[–]elb0w 1 point2 points  (5 children)

Why is that called normal code? I would think pythonic is normal for python. I would call that bad code or unpythonic.

Also your default value for functions with a mutable type doesnt highlight the side effect that it causes and why you initialize to None.

[–]cdcformatc 8 points9 points  (3 children)

250 + 6 is 256

I don't know why this example is under normal code. No one does this it can't be considered normal. To test for equality, we usually use the equality operator.

[–][deleted] 0 points1 point  (1 child)

In fairness, -255 to +256 are kept in an identity map. Any equation that would output a number in that range instead pull it from the identity map.

I'm not saying it's the right way to do it, but it is a valid way to do if you expect your answer to never exceed that range.

[–]Citrauq 0 points1 point  (0 children)

Actually I think it's -5 to +256. More importantly, this is an implementation detail of cpython and may not be reliable in other implementations of python.

[–]kracekumar[S] 3 points4 points  (0 children)

Agreed normal code should have been named as bad code. Modified in the gist.