class Products: productname="" productcode="" productprice="" inst=0 def __init__(self,n="",c="",p=0): if n=="": self.productname="tea"; else: self.productname=n self.productcode=c self.productprice=p Products.inst=Products.inst+1 return def set_productname(self,n): self.productname=n return def get_productname(self): return self.productname def set_productcode(self,c): self.productcode=c return def get_productcode(self): return self.productcode def set_productprice(self,p): self.productprice=p return def get_productprice(self): return self.productprice s=Products("uuyyyu","wqhghgt",111100) print s.get_productname() print s.get_productcode() print s.get_productprice() p=Products("abc","cde",111100) q=Products("abc","cde",111100) h=Products() print q.inst
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