Array design question

Michael P. Soulier msoulier at storm.ca._nospam
Fri May 30 11:44:29 EDT 2003


On Thu, 29 May 2003 11:58:11 +0200, Peter Slizik <peter.slizik at pobox.sk> wrote:
> 
> while( !eof() ) {
>      line = readline();
>      (number, text) = split(line);
>      array[number] = text;
> }
> 
> seems untranslatable into Python. The first attempt to store an object 
> with index 7 into array before other 6 objects are stored there, will 
> cause an exception. But the numbers in the input file aren't in any 
> special order.

    I am sooooo happy this this is not directly translatable into
Python. If I want that kind of flexibility, I'll use Perl, and I do. I
use Python for its strictness, which scales far better into programming
in the large, IMHO. 

    Randomly populating an array is a horrible hack. Use a dictionary if
you need that capability. Arrays are meant to be contigious, and I love
the fact that Python throws ArrayOutOfBounds exceptions, while Perl
silently returns undef and continues. 

    Mike

-- 
Michael P. Soulier <msoulier at digitaltorque.ca>, GnuPG pub key: 5BC8BE08
"...the word HACK is used as a verb to indicate a massive amount
of nerd-like effort."  -Harley Hahn, A Student's Guide to Unix
HTML Email Considered Harmful: http://expita.com/nomime.html




More information about the Python-list mailing list