Two-dimensional arrays

Carl Banks imbosol at aerojockey.com
Tue May 27 16:16:44 EDT 2003


Carl Banks wrote:
> Terry Reedy wrote:
>>> Anybody else here who thinks that this is one of the very few
>>> embarrasing sides of python?
>>
>> What do you think anyone should be embarassed about?  In this respect,
>> Python acts entirely consistently with its object model and its
>> advertised syntax.
> 
> If you think Purity beats Practicality, then there certainly nothing
> to be embarrassed about.
> 
> But the Python Zen is "Practicality beats Purity," and it is currently
> impractical to create a multidimensional array.  I wouldn't go so far
> as to call it embarrassing, but it certainly is inconvenient.  Python
> makes it easy to do something that isn't useful (create a list of
> references to the same sequence), and hard to do something that is.
> That's a problem, and that it "acts entirely consistently with its
> object model and its advertised syntax" doens't make it any less of
> one.


Actually, it isn't that inconvenient or confusing to do this:

[[ None for i in range(10) ] for j in range(10) ]


I stand by my objection, however.  Multidimensional array creation
isn't a problem; but it's because there is a convenient and
straightforward way to do it, not because Python is pure.


-- 
CARL BANKS




More information about the Python-list mailing list