Attach attributes to the class by assigning names to it outside of the original class : Attribute : Class PYTHON TUTORIALS


PYTHON TUTORIALS » Class » Attribute »

 

Attach attributes to the class by assigning names to it outside of the original class


class rec: pass                  

rec.name = 'Bob'                 
rec.age  = 40 

print rec.name                   

x = rec(  )                      
y = rec(  ) 

print x.name, y.name                   
x.name = 'Sue'                   
print rec.name, x.name, y.name 

print rec.__dict__.keys(  )

x.__dict__.keys(  )

y.__dict__.keys(  )
print x.__class__



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Class
» Attribute