Question about consistency in python language

Mike Meyer mwm at mired.org
Fri Sep 9 16:27:22 EDT 2005


Dave Benjamin <dave.benjamin at gmail.com> writes:
> Mike Meyer wrote:
>> Dave Benjamin <ramen at lackingtalent.com> writes:
>>>Python is actually quite consistent in this regard: methods that
>>>modify an object in-place return None;
>> Um, no. list.pop comes to mind as an immediate counterexample. It may
>> be the only one...
> I've never had to look up the return type of "pop" though. The only
> thing even remotely ambigious about that term (at least, if you've
> learned what a stack is) is whether it mutates the object, but I don't
> think I've ever seen a "pop" that didn't (aside from toy examples in
> formal methods / ADT related classes).

Eiffel STACK class has a pop that dosn't return a value - at least in
SmartEiffel. On the other hand, Eiffel makes a *big* deal about the
difference between command features - which change the state - and
query features - which report on the state. That distinction even
shows up in the threading model for Eiffel.

> "os.system" might be a better example, since the return value could be
> one of two obvious things: the status code, or the program's output.

To me, os.system obviously returns the status code. Then again, I know
it's just the unix system() routine, which I've know *much* longer
than there's been a Python.

The point is that what's "obvious" depends on where you're coming
from. If your background is as a Unix developer, the result of
os.system is obvious. If your background is Eiffel or some other
strong ADT area, that pop has a result at all may surprise you.

     <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list