Python 3.0 - is this true?
Aahz
aahz at pythoncraft.com
Sun Nov 9 12:55:06 EST 2008
In article <roy-6896DF.09253809112008 at news.panix.com>,
Roy Smith <roy at panix.com> wrote:
>In article <6no8p6Fm8q70U1 at mid.uni-berlin.de>,
> "Diez B. Roggisch" <deets at nospam.web.de> wrote:
>>attribution missing:
>>>
>>> Also, I thought that part of the python philosophy was to allow any
>>> sort of object in a list, and to allow the same methods to work with
>>> whatever was in list.
>>
>> Not really. When the usual argument about the existence (and
>> justification) of lists & tuples comes along, one common distinction is
>> that
>>
>> - tuples contain arbitrary object of varying types, so they are kind
>> of "records"
>> - lists should contain uniform objects.
>
>I see absolutely nothing wrong with lists of heterogenous types. Or, for
>that matter, iterators which generate heterogeneous types. Here's some
>perfectly reasonable examples (equally applicable to lists or iterators):
>
>* The tokens parsed out of a file (ints, floats, identifiers, keywords,
>various kinds of punctuation, etc)
>
>* The entries in a unix directory (plain files, directories, symlinks,
>special files, named sockets, etc)
>
>* The vehicles going through a toll booth (cars, trucks, motorcycles)
>
>I don't see any reason you shouldn't be able to build lists of those things.
Overall agreed, but I think your reasoning breaks down when you talk
about sorting such a list: generally speaking, when you create a list
like that, it's because you specifically want to preserve ordering.
The case where it's mostly like you'd want to sort (entries in a Unix
directory), you can arguably reduce the discussion to string sorting
quite easily.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"It is easier to optimize correct code than to correct optimized code."
--Bill Harlan
More information about the Python-list
mailing list