Enums and Python

Dan Schmidt dfan at harmonixmusic.com
Wed Jun 21 09:28:19 EDT 2000


"William Dandreta" <wjdandreta at worldnet.att.net> writes:

| 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.

I think it's exactly the opposite.  If you want to look things up by a
name rather than a number, look them up by a name, not by a fake name
that actually maps to a number.  Trying to shoehorn your 'Date, Foo,
Bar' fields into an array is the contrivance.

Perhaps you come from a background in languages like C?  Often it
takes a while to get used to writing code the way you think, without
worrying too much about overhead and exactly how the computer is
laying out your data in memory.

-- 
                 Dan Schmidt | http://www.dfan.org
Honest Bob CD now available! | http://www.dfan.org/honestbob/cd.html



More information about the Python-list mailing list