Newbies: Re: Returning none

Phil Hunt philh at vision25.demon.co.uk
Fri Sep 3 19:08:03 EDT 1999


In article <37CF5499.BA24C33E at prescod.net>
           paul at prescod.net "Paul Prescod" writes:
> I want to make the empirical point that I brought up this None issue
> when two different co-workers ran into the problem in three different
> contexts in one statistically unlikely week. 
> 
> #1. a=list.sort("abc"): "None object has no attribute foo" 

I think in this kind of case there is room for 2 functions: one
that sorts the list; another that leaves the list unchanged, and
returns a sorted version of the list. Perhaps these could be:

i.    list.sort()
ii.   result = list.sorted()

> #2. alert( print_traceback() ): "None"
> 
> #3. Forgetting to return a value.

I quite like the feature of Smalltalk where if you don't specify
the return vcalue, it returns the object that was the receiver of
the method.

-- 
Phil Hunt - - - - - - - - -  philh at vision25.demon.co.uk
 - Linux will be 8 years old on 17th September! See: -
http://www.vision25.demon.co.uk/prog/linuxbirthday.html





More information about the Python-list mailing list