JavaScript's void operator in Python?

Jon Ribbens jon+usenet at unequivocal.eu
Sun Feb 2 18:06:50 EST 2020


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.


More information about the Python-list mailing list