Facebook
From kush, 4 Years ago, written in Plain Text.
This paste is a reply to Re: 7 from kush - view diff
Embed
Download Paste or View Raw
Hits: 331
  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.     @classmethod
  9.     def from_string(cls, person_str):
  10.         l=person_str.split(",")
  11.         cls.__name=l[0]
  12.         cls.__age=int(l[1])
  13.         p=Person(cls.__name,cls.__age)
  14.         return(p)
  15.     def initialize_counter(value):
  16.         Person.counter=value
  17.     def __str__(self):
  18.         return("%s is %s years old and her id is %s" %(self.__name,self.__age,self.__id))
  19.                
  20.  

Replies to 8 rss

Title Name Language When
9 kush text 4 Years ago.