[Guido] > > - The set constructors have an optional second argument, sort_repr, > > defaulting to False, which decides whether the elements are sorted > > when str() or repr() is taken. I'm not sure if there would be > > negative consequences of removing this argument and always sorting > > the string representation. [François] > Unless there is something deep attached to the properties of the sets > themselves, I do not understand why the sorting/non-sorting virtues of > `repr' should be tied with the constructor. > > There is a precedent with dicts. They print non-sorted, but they > pretty-print (through the `pprint' module) sorted. Maybe the same could > be done for sets: use `pprint' if you want a sorted representation. > But otherwise, sets as well as dicts should print using the same order > by which elements are to be iterated upon or listed, in various other > circumstances. This is a pretty convincing argument. If dicts can survive being rendered unsorted, then so can Sets. Maybe I should remove the sort_repr argument altogether; it's easy enough for the test suite to use some other trick. But for now, I'll just leave sort_repr=False in. I'm gonna check this in now, but that doesn't mean we can't tweak the API or implementation, so keep those comments coming! --Guido van Rossum (home page: http://www.python.org/~guido/)
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