"None" and "pass"

Ben Finney ben+python at benfinney.id.au
Mon Feb 5 16:39:39 EST 2018


Chris Angelico <rosuav at gmail.com> writes:

> As one special case, I would accept this sort of code:
>
> def f():
>     ...
>
> (three dots representing the special value Ellipsis)
>
> It's a great short-hand for "stub".

I would not accept that.

An even better way to write a stub function is to write a docstring:

    def frobnicate():
        """ Frobnicate the spangule. """

A docstring, like any bare expression, is also a valid statement.
Writing a docstring can be done immediately, because if you're writing a
stub function you at least know the external interface of that function.

-- 
 \           “If you do not trust the source do not use this program.” |
  `\                                —Microsoft Vista security dialogue |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list