"None" and "pass"

Alain Ketterlin alain at universite-de-strasbourg.fr.invalid
Mon Feb 5 14:47:44 EST 2018


ram at zedat.fu-berlin.de (Stefan Ram) writes:

>   A participant of my Python course asked whether one could
>   also use "None" instead of "pass". What do you think?
>
> def f():
>     pass
>
>   can also be written as
>
> def f():
>     None
>
>   . Is there any place where "None" could not be used 
>   instead of "pass"?

No, an expression is always a valid statement:

    https://docs.python.org/3.6/reference/simple_stmts.html

Use None, or 42+0, or 1+1+1+1+1+1+1+1+1, or whatever you want (that does
not have any side-effect and/or throw an exception). And be fired right
after your first code review.

-- Alain.



More information about the Python-list mailing list