A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2010-March/720301.html below:

Adding to a module's __dict__?

Adding to a module's __dict__?Mel mwilson at the-wire.com
Tue Mar 2 09:26:06 EST 2010
Roy Smith wrote:
[ ... ]
> Why is it unwise?
> 
> The use case is I'm importing a bunch of #define constants from a C header
> file.  I've got triples that I want to associate; the constant name, the
> value, and a string describing it.  The idea is I want to put in the
> beginning of the module:
> 
> declare('XYZ_FOO', 0, "The foo property")
> declare('XYZ_BAR', 1, "The bar property")
> declare('XYZ_BAZ', 2, "reserved for future use")
> 
> and so on.  I'm going to have hundreds of these, so ease of use, ease of
> maintenance, and niceness of presentation are important.

As long as the header file says what you think it says, you're fine.  If you 
encounter a file that does "#define sys", then the sys module is forever 
masked, and your module can't invoke it.  A header file that contains 
"#define declare" will be fun.

	Mel.



More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4