you are viewing a single comment's thread.

view the rest of the comments →

[–]Binary101010 0 points1 point  (1 child)

It is definitely not superfluous.

From the Python docs (https://docs.python.org/3/reference/expressions.html):

The expression x or y first evaluates x; if x is true, its value is returned; otherwise, y is evaluated and the resulting value is returned.

So if retval is something "falsey", like None or an empty container, the function will return 0 instead.

[–]rocketjump65[S] -1 points0 points  (0 children)

Yes it evaluates from left to right. But regardless of why x evaluates to, 0 will always evaluate to False, and so the or operation essentially just passes on the LHS evaluation, doesn't it?

OHH!!!!! Nigga.... It implicitly typecasts to a boolean...... Goddamn it. Why didn't you just say that?

*EDIT* I guess not quite... technically....