A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-August/028077.html below:

[Python-Dev] PEP 218 (sets); moving set.py to Lib

[Python-Dev] PEP 218 (sets); moving set.py to LibMichael McLay mclay@nist.gov
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):
...     _sort_repr=False
...     __slots__ = ["_data"]
...    def __init__(self....

>>> class SortedSet(Set):
...     _sort_repr=True
...
>>> ss = SortedSet()
>>> s = Set()
>>> s._sort_repr
False
>>> ss._sort_repr
True




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4