class Transaction: tid = '' date = '' totalsale = '' def __init__(self, i, d, s): self.tid = i self.date = d self.totalsale = s return def getprofile(self): print 'ID:'+self.tid print 'DATE:'+self.date print 'TOTAL SALES:'+str(self.totalsale) return def __str__(self): st = 'Transaction ' return st class childtran(Transaction): def __init__(self, n, qt, i, d, s ): Transaction.__init__(self,i,d,s) self.name = n self.qty = qt return def getprofile(self): #Transaction.getprofile(self) #print 'NAME:\t'+self.name print 'QTY:\t'+self.qty return def __str__(self): stt = 'childtran ' return stt y = childtran('Sony Vaio','120', '12100SONY','30MAY2014',1111) print y y.getprofile() x = Transaction('12100SONY','30MAY2014',1111) print x
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question