Question about consistency in python language
Erik Max Francis
max at alcyone.com
Thu Sep 8 23:43:42 EDT 2005
Dave Benjamin wrote:
> 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'm sure there are counterexamples... maybe 95% is too optimistic.
> Anyone want to volunteer to compile some stats? ;)
Well, that's because list.pop mutates a list _and_ returns something
meaningful (not the list itself). One could modify the above statement
about consistency to say that methods which modify an object and do not
return a directed value do not return the object which was mutated, but
rather return None. So list.append returns None, but list.pop returns
the element popped.
--
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
Nobody's interested in sweetness and light.
-- Hedda Hopper
More information about the Python-list
mailing list