Why return None?

Antoon Pardon apardon at forel.vub.ac.be
Thu Aug 26 11:41:22 EDT 2004


Op 2004-08-26, Alex Martelli schreef <aleaxit at yahoo.com>:
> Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:
>
>> aleaxit at yahoo.com (Alex Martelli) writes:
>> > There should be one-- and preferably only one --obvious way to do it.
>> > 
>> > Not leaving stylistic choice (which would lead to more than one obvious
>> > way to do it) is quite consonant with the Zen of Python.
>> 
>> Well, what you're left with is that doing it the one obvious way
>> doesn't work, and you have to do it in some contorted way instead.
>
> If somelist.sort() returned the list there could not possibly be one
> obvious way to do it, since both
>
> print somelist.sort()
>
> and
>
> somelist.sort()
> print somelist

Then python has already deviated from the one obvious way to do it.
I can do:

  a = a + b   vs    a += b.

or

  a = b + c   vs     a = ''.join(b,c)


The difference between

  print somelist.sort()

and

  somelist.sort()
  print somelist


is IMO of the same order as the difference between


  print a + b

and

  r = a + b
  print r


-- 
Antoon Pardon



More information about the Python-list mailing list