Question by someone coming from C...

Skye spoier at gmail.com
Mon Jun 9 17:00:39 EDT 2008


Writing this app in Python, not sure what the "best practice" would
be.

I want a bitfield global logging level that allows me to turn specific
debugging modules on and off.  If I was doing this in C, I'd just use
some globals like:

unsigned int debug_level = 0;
#define DEBUG_GENERAL 0x0001
#define DEBUG_CONFIG 0x0002
#define DEBUG_OPTIONS 0x0004
etc etc

So I guess my questions are:

1. there doesn't seem to be a way to define global constants like in
other languages?
2. any  special voodoo to use bitfields in Python?

Thanks!
Skye




More information about the Python-list mailing list