Enums and Python

William Dandreta wjdandreta at worldnet.att.net
Wed Jun 21 02:30:10 EDT 2000


Hi Cameron,

What I am doing is reading a comma delimited text file like this

line = AB12345,20000621,3.56,...

fields = splitfields(line,',')

recognizing that

fields[Date][:5]  is the year

is more obvious and less cryptic than

fields[1][:5]

Trying to put this into a dictionary seems a contrivance to me that doesn't
make things clearer and only adds overhead.

Maybe after I get more used to using dictionaries, I'll change my mind.

I am using dictionaries somewhat but sometimes is it hard to know which data
structure is best.

I rewrote a program to day using dictionaries instead of lists which
simplified the code and speeded things up by a factor of 3 or 4. I am
beginning to appreciate their value.

Bill
Cameron Laird wrote in message ...
>I'll say that more forcefully than Aahz does here:  while
>enums are often a marker of good taste in C coding, Python
>generally achieves the same results with a considerably
>cleaner reformulation in terms of dicts.  If you feel a
>need for enums while writing Python, you're probably missing
>out on a better (and not-so-reminiscent-of-C) coding.
>
>I've become rather dogmatic on this point.  I need the
>practice of working to falsify it.  If you have a specific
>algorithm you can share that you see as ripe for a Python
>enum, please tell us here; maybe we can suggest an
>alternative.
>--
>
>Cameron Laird <claird at NeoSoft.com>
>Business:  http://www.Phaseit.net
>Personal:  http://starbase.neosoft.com/~claird/home.html





More information about the Python-list mailing list