[Python-ideas] Set Syntax
masklinn at masklinn.net
Wed Nov 24 09:58:34 CET 2010
On 2010-11-24, at 00:53 , average wrote:
> On Tue, Nov 23, 2010 at 3:18 PM, Mike Graham <mikegraham at gmail.com> wrote:
>> On Tue, Nov 23, 2010 at 5:16 PM, average <dreamingforward at gmail.com>
>>> On Tue, Nov 23, 2010 at 12:59 PM, Guido van Rossum <guido at python.org>
>>>> FWIW I'm fine with adding list.clear() to 3.3.
>>> How about calling it container.clear()? ;^)
>> 1) Because that's not how Python's type system works, and
>> 2) Because many containers are immutable?
>> That's a decent point. But in the case of a non-uniform container scheme
> and in absence of a obvious syntax to distinguish between mutable and
> immutable types, then it doesn't really make much sense to add the clear
> method to lists.... yet
That's a pretty terrible point: sets have a .clear() method, frozensets don't. Dicts have a .clear() method, if functional maps were added to the language they probably wouldn't. Mutable collections have a .clear() method, immutable collections don't. You can only mix them (mutable and immutable methods) when reading them (in which case you don't care for the .clear() method anyway) so it's not like it matters.
More information about the Python-ideas