Facebook
From Sweltering Pig, 5 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 47
  1. class Person:
  2.     counter = 0
  3.     def __init__(self,name, age):
  4.             self.__name = name
  5.             self.__age = age
  6.             Person.counter = (int) (Person.counter) + 1
  7.             self.__id = Person.counter
  8.        
  9.     @classmethod
  10.     def from_string(cls, person_str):
  11.         a=person_str.split(",")
  12.         return cls(a[0],a[1])
  13.     @staticmethod
  14.     def initialize_counter(value):
  15.         Person.counter = value
  16.     def __str__(self):
  17.         return self.__name + " is " + self.__age + " years old and her id is "+str(self.__id);
  18.                
  19.  
  20.                
  21.                
  22.