JavaScript's void operator in Python?
Jon Ribbens
jon+usenet at unequivocal.eu
Sun Feb 2 09:46:07 EST 2020
On 2020-02-02, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
> JavaScript has a void operator that maps everything to
> undefined. E.g.,
>
> JavaScript console
>
>|< void( console.log( 2 ) )
>| 2
>|> undefined
>
> I can easily write a corresponding function in Python.
>
> main.py
>
> def void( x ):
> pass
>
> void( ( print( 2 ), print( 3 )))
>
> transcript
>
> 2
> 3
>
> . But is an operator or a function like that already
> defined in Python or its standard library?
I'm not sure why you'd want to - but "None and foo" is an expression
that will return None regardless of the value of "foo".
More information about the Python-list
mailing list