No trees in the stdlib?
MRAB
python at mrabarnett.plus.com
Wed Jul 1 12:21:54 EDT 2009
Lawrence D'Oliveiro wrote:
> In message <mailman.2140.1245996088.8015.python-list at python.org>, João
> Valverde wrote:
>
>> Simple example usage case: Insert string into data structure in sorted
>> order if it doesn't exist, else retrieve it.
>
> the_set = set( ... )
>
> if str in the_set :
> ... "retrieval" case ...
> else :
> the_set.add(str)
> #end if
>
> Want sorted order?
>
> sorted(tuple(the_set))
>
> What could be simpler?
>
Why not just "sorted(the_set)"?
More information about the Python-list
mailing list