osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

JavaScript's void operator in Python?


On 2020-02-02, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
> Greg Ewing <greg.ewing at canterbury.ac.nz> writes:
>>If the functions you're calling all return None, you can
>>do this:
>> >>> print(2); print(3)
>
>   ?print(2); print(3)? is not an expression anymore but an stmt_list.
>   It cannot be used in all places where an expression is allowed.

Why does it matter if the return value is None?

"print(2), print(3)" is an expression that will evaluate all of its
sub-expressions. If the sub-expressions return None then I guess you
could do "(x, y, z)[0]" too.