Why list.sort() don't return the list reference instead of None?
sybrenUSE at YOURthirdtower.com.imagination
Mon May 8 09:26:19 CEST 2006
ankyhe at gmail.com enlightened us with:
> However, I wonder why L.sort() don't return the reference L, the
> performance of return L and None may be the same.
It's probably because it would become confusing. Many people don't
read the documentation. If L.sort() returns a sorted version of L,
they would probably assume it didn't do an in-place sort. The effects
of an unexpected in-place sort are much harder to track down and debug
than a function returning None.
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
More information about the Python-list