Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
Question about a single underscore.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Steven W. Orr, post: 2055854"] On Thursday, Feb 1st 2007 at 09:25 -0800, quoth Bart Ogryczak: =>> I saw this and tried to use it: =>> =>> ------------------><8------------------- const.py------------- =>[...] =>> sys.modules[__name__]=_const() => =>__name__ == 'const', so you´re actually doing =>const = _const() So how can I say this in const.py? class _const: class ConstError(TypeError): pass def __setattr__(self,name,value): if self.__dict__.has_key(name): raise self.ConstError, "Can't rebind const(%s)"%name self.__dict__[name]=value def __init__(self): sys.modules[self]=_const() import sys to cause a different instantiation a la foo = _const() The goal would be to create different instances of consts. I did try the previous suggestion irrational_consts = _const() but I got Traceback (most recent call last): File "<stdin>", line 1, in ? NameError: name '_const' is not defined *>>> iii=const() Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: _const instance has no __call__ method ------------ For ref: class _const: class ConstError(TypeError): pass def __setattr__(self,name,value): if self.__dict__.has_key(name): raise self.ConstError, "Can't rebind const(%s)"%name self.__dict__[name]=value import sys sys.modules[__name__]=_const() -- Time flies like the wind. Fruit flies like a banana. Stranger things have .0. happened but none stranger than this. Does your driver's license say Organ ..0 Donor?Black holes are where God divided by zero. Listen to me! We are all- 000 individuals! What if this weren't a hypothetical question? steveo at syslang.net [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
Question about a single underscore.
Top