Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Student1:
- def __init__(self, name, email):
- self.name = name
- self.email = email
- @classmethod
- def stu_details(cls, name, email):
- return cls(name, email)
- @classmethod
- def details(cls, student_instance):
- print(student_instance.name, student_instance.email)
- def student_details(self):
- print(self.name, self.email)
- def result(self):
- print(self.name, "is passed")
- # Creating an instance using classmethod
- su = Student1.stu_details("ram", "ram@gmail.com")
- # Calling instance method student_details
- su.student_details()
- # Calling class method details
- Student1.details(su)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement