imperative mood in docstrings

Chris Angelico rosuav at gmail.com
Sun Feb 9 17:12:45 EST 2014


On Mon, Feb 10, 2014 at 4:53 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
> Shouldn't that be:
>
>   class Pig:
>       def fly(self):
>       "Soar gracefully through the air if a hot place is very cold."
>           if hell is frozen:
>               self.sprout_wings()
>               self.altitude += 10
>               self.velocity += 25
>           else:
>               self.splat()
>
> ;)

The Python 'is' operator does not do what you think it does. If it
did, 'hell is frozen' would mean that one could say 'war is frozen',
which makes no sense. No, I think this calls for a LISP-style
predicate:

if frozenp(hell):

ChrisA



More information about the Python-list mailing list