473,396 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

best way to have enum-like identifiers?

mh
I currently have a 2-dim hash, indexed by two strings:

template['py']['funcpre']
template['py']['funcpost']
...

but I would prefer to have these indexed by constants of
some kind, since this seems a bit more natural:

template[py][funcpre]
template[py][funcpost]
...

Currently I'm just putting this at the top of the file:

py=1
funcpre=2
funcpost=3
...

but I'm curious if there's a better way of doing this,
some kind of enum-like thing or somesuch.

Many TIA!
Mark

--
Mark Harrison
Pixar Animation Studios
Mar 12 '08 #1
1 1131
mh@pixar.com writes:
Currently I'm just putting this at the top of the file:

py=1
funcpre=2
funcpost=3
...
That can be done more compactly with

py, funcpre, funcpost = range(3)

give or take 1.

but I'm curious if there's a better way of doing this,
some kind of enum-like thing or somesuch.
https://launchpad.net/munepy describes itself as yet another Python
enum implementation. Its author is Barry Warsaw.
--
Pete Forman -./\.- Disclaimer: This post is originated
WesternGeco -./\.- by myself and does not represent
pe*********@westerngeco.com -./\.- the opinion of Schlumberger or
http://petef.22web.net -./\.- WesternGeco.
Mar 12 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: Michael C | last post by:
If a class inherits from another class, say Form inherits from control, then I can assign the Form to a variable of type Control without needing an explicit conversion, eg Form1 f = new Form1();...
13
by: john doe | last post by:
A quick question, about so-called 'best practices', I'm interested in which of A/B of the two examples people would choose, and why. public enum MyEnum { Option1 = 0, Option2 = 1, Option3 =...
4
by: Shayne H | last post by:
What is the best way to enumerate a grouping of strings? The way I have been doing it is: Public Enum PlatformID Unknown Win16 Win32 Win32NT WinCE End Enum
2
by: Dennis | last post by:
I have an enum as follows: Public Enum myData FirstData = 6 SecondData = 7 end enum Is there anyway that I can return the Enum names by their value, i.e., I want to input 6 into a function...
1
by: Randy | last post by:
Hi, I downloaded and tried the ENUM++ code from CUJ http://www.cuj.com/documents/s=8470/cujboost0306besser/ but can't even get it to compile (see following). I have also downloaded and...
2
by: Randy | last post by:
Hi, I downloaded and tried the ENUM++ code from CUJ http://www.cuj.com/documents/s=8470/cujboost0306besser/ but can't even get it to compile (see following). I have also downloaded and...
9
by: Jacek Dziedzic | last post by:
Hi! I often find that my programs need to store information on "current mode of something" with two or at most several mutually exclusive "modes" to choose from, e.g. - datafile: is it in a)...
3
by: Michael A. Covington | last post by:
I have a class A which contains an arraylist of another class, B, which is rarely used separately. So I nested B within A. I also have an enum of the values of one of the items within B. Call...
0
by: joshfink | last post by:
Hey guys, I am writing an application where I want to follow the best practices on error handling. This is what I have: I created an enum for various issues that could happen within the...
4
by: Andy Champ | last post by:
What I want to do (and can't...) is Template <typename Tclass base { // whatever } class derived: public base<derived::myVals> { Enum myVals
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.