On 7/13/2010 4:22 AM, Gregory Ewing wrote:
John Nagle wrote:
Arguably, if a function just does a "return",
it should be an error to try to use its return value.

It's been suggested at least once before that the
default return value for a function should be some
special value that raises an exception if you try
to do anything with it except throw it away.

    Treating that case as an error would be consistent with the
way attribute access works in Python.  In Python, attempting
to access a nonexistent attribute raises an exception.  In
Javascript, that returns a null.  Javascript makes no
distinction between "null" and "nonexistent", but Python
does.

    It's un-Pythonic and inconsistent that functions which
return nothing are considered to return a None object.

                                John Nagle
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to