<br><br><div class="gmail_quote">On Fri, Jun 27, 2008 at 5:25 PM, Maric Michaud <<a href="mailto:maric@aristote.info">maric@aristote.info</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Yes it is, but it's rather unneeded in Python, we prefer simply create a<br>
module level dictionnary, these tricks are used in language like C++ or Java.<br>
<br>
In python :<br>
<br>
mymodule.py :<br>
<br>
ModuleOptions = {}<br>
<br>
othermodule.py :<br>
<br>
import mymodule<br>
<br>
mymodule.ModuleOptions['Verbose'] = True<br>
<br>
or if you think encapsulation is important :<br>
<br>
mymodule.py :<br>
<br>
_ModuleOptions = {}<br>
<br>
def get_option(opt) :<br>
    return _ModuleOptions[opt]<br>
....<br>
<br>
And you're done.<br>
<br></blockquote></div><br>Using a module level instance seems the right way to go. I'm trying something like this.<br><br>mymodule.py:<br>class MyDict( dict):<br>   ...<br>   ...<br>MyDict = MyDict()<br><br><br>othermodule.py:<br>
import mymodule<br>print mymodule.MyDict<br><br>I'm running into a slight problem however that my run-time defined logging level is not correctly set until after the module has initialized, preventing any log messages from showing up. Is there a pythonic way to get around this? I'm thinking of adding a module init routine, but I don't feel like this is clean solution.<br>
<br>- Casey<br>