Re: My other pet python peeve - .sort(),.reverse(), etc. return None

Steven D. Majewski (sdm7g@elvis.med.virginia.edu)
Tue, 14 Sep 1993 03:08:18 -0400

On Sep 13, 23:01, Tim Peters wrote:
> > ...
> > ( And I can't even think of some likely + reasonable code that would
> > be broken by the change. ...
>
> For a reasonable counterexample, how about every program you have <0.1
> grin>? That is, whenever you have
>
> thing.sort()
>
> now, it yields None, and _because_ it yields None specifically, Python
> doesn't print the value:
>
> So if thing.sort() (or reverse or append) were to return the sorted
> (reversed, appended) object instead, every existing line like that would
> start producing output. Yeech!
>

O.K.
So, besides that ONE *little* problem <embarassed grin :->
what's wrong?

And yes - the obvious work around has ocurred to me, and I've used it
a few times. But if *I* feel the need to redefine sort, and _if_ you and
others also feel it is awkward ( I don't know if that IS the case ),
then I'd say it IS a mis-feature. ( though clearly not as easy to fix
transparently as I had thought. )

Honestly - this has not been a major problem for me. One reasone I'm
bringing it up is that python release 0.9.9, as well as the "Great
Renaming" has me thinking about becomming a more active "Python
Evangelist". We've been through a couple of syntax changes, but I
have sort of assumed that by the time we get to version 1.0 release,
the language, ( if not the implementation ) will essentially be
stable. ( with perhaps some upwardly compatible extensions. )
So the approach of that event has made me a bit "picky" - I feel
it's "speak now or forever hold your peace!" And I feel that this
is one of the "non-intuitive" features of python that new users
might stumble over a few times.

[ The same goes for my pickiness about "array.read( file, count )" ]

Which is also why I'm concerned with the normal default bahaviour,
rather than how I can fix it for me. I'm not sure if I can
transparently change the default behaviour without having to
remember to import MY definitions - maybe I can do it with an
init file, so that it gets imported into the global namespace.
Certainly, I could change C source and rebuild *MY* copy of
python to do what *I* want. But then I'ld just get used to
( and learn to take for granted ) what for everyone ELSE is
the wrong behaviour.

I don't think it bugs me THAT much, that I'ld become an island
among python users. ( Any idea how many of us there are? )

[ Although, I might be tempted to try it as an experiment, to
see HOW many pieces of code the change might actually break,
and how badly. ]

- Steve M.