[Python-Dev] PEP 218 (sets); moving set.py to Lib
Tue, 20 Aug 2002 13:10:18 -0400
On Monday 19 August 2002 04:38 pm, Guido van Rossum wrote:
> > [Guido van Rossum]
> > > OTOH what then to do with _sort_repr -- make it a class var or an
> > > instance var?
> [Brett C]
> > Well, how often can you imagine someone printing out a single set sorted,
> > but having other sets that they didn't want printed out sorted? I would
> > suspect that it is going to be a very rare case when someone wants just
> > part of their sets printing sorted and the rest not.
> > I say make it a class var.
> Hm, but what if two different library modules have conflicting
> requirements? E.g. module A creates sets of complex numbers and must
> have sort_repr=False, while module B needs sort_repr=True for
> user-friendliness (or because it relies on this).
Adding a SortedSet class to the module would partially solve the problem of
globally clobbering the usage of Set in other modules. The downside is that
the selection of the sort function would be a static decision made when when
a set instance is created.
>>> class Set(object):
... __slots__ = ["_data"]
... def __init__(self....
>>> class SortedSet(Set):
>>> ss = SortedSet()
>>> s = Set()