python needs leaning stuff from other language
robert.kern at gmail.com
Sat Apr 4 09:03:07 CEST 2009
On 2009-04-03 23:48, Tim Wintle wrote:
> On Fri, 2009-04-03 at 18:27 -0500, Robert Kern wrote:
>>> agreed. If .clear was to be added then really assignments to slices
>>> should be entirely removed.
>> Please tell me you are joking.
> Well I'm not joking as such.
> I've noticed that python-ideas seems to be positive on the idea, and has
> a patch ready for Guido, obviously I'm not that anti it that I'd always
> be complaining if it is implemented, I just see it as unnecessary:
Let's be clear: python-ideas seems positive on the idea of adding a .clear()
method. *Completely removing* slice assignment has not been broached there.
> (I didn't expect such strong responses btw!)
You are proposing the removal of a general, orthogonal feature (and breaking
code in consequence!) just because of a new syntax for a single special case of
that feature. That is quite simply ridiculous.
.clear() would be non-orthogonal syntactic sugar. That's okay! Python has
syntactic sugar in a number of other places, too! Appropriate doses of syntactic
sugar and non-orthogonality are precisely what lets you implement "There should
be one-- and preferably only one --obvious way to do it." The really key word in
that sentence is "obvious", not "one".
FWIW, removing slice assignment would be a gross form of non-orthogonality, too.
__getitem__, __setitem__ and __delitem__ should all be able to accept the same
indices (or else raise exceptions in the case of immutability).
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list