Home > other >  Python: the small white, instance of the class as a property
Python: the small white, instance of the class as a property

Time:12-09

GBK # coding:
Class Restaurant () :
Def __init__ (self, the name, type) :
The self. The name=name
Self. Type=type
The self. The boss='duanzebing'
Def the describe (self) :
Print (self. 'is' name + + self. Type)
Def open (self) :
Print (self. The name + 'are the business')
Def up (self, na) :
The self. The boss +=na
The class Lidan (Restaurant) :
Def __init__ (self, the name, type, flavors) :
Super () __init__ (name, type)
Self. Flavors=flavors
# for the I in the self. Flavors:
Print (self. The name + self. Type + self. Flavors)
Def ceshi (self) :
Print (' test ')
The class Privileges () :
Def __ini__ (self) :
The self. A='x'
Self. Privileges1=Lidan ()
# print (' 0 ')
My_baby=Lidan (' xx ', 'like', 'chess')
# print (' 1 ')
My_cla=Privileges ()
My_cla. Privileges1. Ceshi ()
Code as above, I have a small white, just look at the book self-study to instance attributes, the result how also not to come out, the last call has been an error, I don't know where is wrong, for,
  • Related