question of style

John Yeung gallium.arsenide at gmail.com
Fri Jul 3 19:26:39 EDT 2009


On Jul 3, 4:50 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> I wouldn't say Python's None is terrible, but the
> programming style in which None is used as a marker
> for "absent value" is genuinely a source of bugs,
> requiring care when used.  Often it's easy to just
> avoid it and all the bugs that come with it.

While other languages may make it easier to avoid these types of bugs,
I think it's pretty natural to use Python's None as a marker for
"absent value", if you're coding in Python.  Python seems to encourage
this by having functions return None when there is no explicit return
value, and by having the interactive command line print nothing at all
when the expression evaluates to None.

I won't argue with anyone who wants to call these design flaws, but it
seems to me that using None this way in one's own Python code is
reasonably Pythonic.

John



More information about the Python-list mailing list