a question about python

  • Thread starter §õ¥Õ¡A¦r¤@¤é
  • Start date
§

§õ¥Õ¡A¦r¤@¤é

hi,
i have a question on python programming.

let file a.py has a class named a,
class a():
__G__ = "1111"

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?
 
S

Steven D'Aprano

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"
 
Æ

æŽç™½ï¼Œå­—一日

thanks.

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




import a
a.a.__C__ = "22222"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,129
Latest member
FastBurnketo
Top