very good reasons?

Glyph Lefkowitz glyph at no.spam
Fri Sep 29 19:48:09 EDT 2000


Grant Griffin <g2 at seebelow.org> writes:

> >If you could write
> >
> >  sorted_arr = arr.sort()
> >
> >then people might get surprised that arr changed.
> 
> Well, I had thought of that, but it didn't really seem compelling to me: I can't
> find anything in Tim's "Python Philosophy"* that it specifically violates.
> 
> (unlike-some-of-2.0's-new-features-<wink>)-ly y'rs,

"Explicit is better than implicit."

If you say "sorted = arr.sort(); foo(sorted)", you're only implying
that arr changed, whereas if you say "arr.sort(); foo(arr)" you're
stating it explicitly.

-- 
Glyph Lefkowitz
Professional -- Software Engineer,  Origin Systems
Amateur      -- Computer Scientist, Twisted Matrix Enterprises
(My opinions are my own and do not reflect in any way on the policies
or practices of my employer, etcetera etcetera.)



More information about the Python-list mailing list