Facebook
From Mustard Agouti, 5 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 44
  1. class Person:
  2.     counter=0
  3.     def __init__(self,name,age):
  4.         Person.counter+=1
  5.         self.name= name
  6.         self.age = age
  7.     def __str__(self):
  8.         return  self.name +" is "+ self.age+" years old"
  9.     @classmethod
  10.     def from_string(cls,personstr):
  11.         a=personstr.split(",")
  12.         return Person(a[0],a[1])