Time we switched to unicode? (was Explanation of this Python language feature?)

Ian Kelly ian.g.kelly at gmail.com
Thu Mar 27 08:43:41 CET 2014


On Thu, Mar 27, 2014 at 1:32 AM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Tue, Mar 25, 2014 at 7:36 AM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
>> Yes, Python could have changed the meaning of {} to mean the empty set.
>> But you know what? The empty set is not that important. Sets are not
>> fundamental to Python. Python didn't even have sets until 2.3, and at
>> first they were just a standard library module, not even built-in. Dicts,
>> on the other hand, are fundamental to Python. They are used everywhere.
>> Python is, in a very real sense, built on dicts, not sets. You can
>> implement sets starting from dicts, but not the other way around: dicts
>> are more fundamental than sets.
>
> Challenge accepted!

Oops, I forgot to allow for a 0-argument constructor.  Please revise
the SetBasedDict.__init__ method to:

    def __init__(self, initial=(), **kwargs):
        self._contents = set()
        if initial or kwargs:
            self.update(initial, **kwargs)



More information about the Python-list mailing list