c enum - how to do this in python?

Rene Pijlman reageer.in at de.nieuwsgroep
Fri Feb 21 17:50:12 EST 2003


Klaus Meyer:
>>> enum { M0, M1, M2, MCOUNT };
>>> How to do this in Python?
>>
>> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/67107
>
>Thanks, but surprisingly complex in Python...

I agree, but compare Java, just for fun...
http://www.javaworld.com/javaworld/javatips/jw-javatip122.html

I'm not sure where things went wrong in computer science. 

C lacks a byte data type, even though it basically treats
everything as a contiguous array of bytes. Python is a high
level programming language including bolean logic, but until
recently it lacked a boolean datatype. enum is a basic concept
in a primitive language like C, but it needs to be emulated with
unreasonably complex constructs in high level languages like
Java and Python. And now we get the perlish smiley [::-1]
meaning: return me upside down. Strings are immutable and
constants are not. Spaces can be syntax errors.

What were those language designers thinking?

"yelims tluafed .p.l.c eht rof detanimoN"[::-1]

-- 
René Pijlman

Wat wil jij leren?  http://www.leren.nl




More information about the Python-list mailing list