Home > other >  New python for help outside class attribute value changed for help
New python for help outside class attribute value changed for help

Time:04-30

 
The class MainEnum (Enum) :
Num=1
ABC=2
Pass
The class Maindata:
Num: int
Def __init__ (self) :
The self. The num=1000
ABC=1000
the self.Pass

Def one (self, py: MainEnum) :
Print (py)
Print (self. Num)
Pass

Pass

The main=Maindata ()
The main one (MainEnum. Num. Name)


O
 
Num
1000



Code in just learning python interface to invoke a month because do want to do mainEnum enumeration values to let he can't write wrong attribute
In the calling class Maindata one incoming I defined attribute string
Want to let self. P y=& gt; Into the self. Num and then modify the corresponding attribute value
But I know the python code error there is a way for the getattr () and setattr () can solve this problem but properties more than one word will increase cost
Still want to use the self. The way to solve for you great god given solution
  • Related