a question about python

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Thu Nov 26 04:45:51 EST 2009


On Thu, 26 Nov 2009 01:21:39 -0800, 李白,字一日 wrote:

> hi,
> i have a question on python programming.
> 
> let file a.py has a class named a,
>   class a():
>     __G__ = "1111"


Methods with double leading and trailing underscores are reserved for 
Python's special use. You should find a different naming convention.


> in file b.py i need to insert an attribute __C__ to class a
> 
> it would be as if class a defined in file a.py like this:
>   class a():
>     __G__ = "1111"
>     __C__ = "22222"
> 
> how this be done in python without inheritance?


import a
a.a.__C__ = "22222"



-- 
Steven



More information about the Python-list mailing list