Facebook
From 7, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 126
  1. class Person:
  2.     def __init__(self,name, age):
  3.             self.__name = name
  4.             self.__age = age   
  5.     @classmethod
  6.     def from_string(cls,person_str):
  7.         x,y=person_str.split(",")
  8.         obj=cls(x,y)
  9.         return obj
  10.        
  11.     def __str__(self):
  12.         return (self.__name+" is "+str(self.__age)+" years old")
  13.        
  14.        
  15.  
  16.  
  17.        
  18.                
  19.  
  20.                
  21.                
  22.