Skip to content

Instantly share code, notes, and snippets.

@mertdotcc
Created June 24, 2020 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mertdotcc/094152607b09b42e4a6d88fa4e53a7b4 to your computer and use it in GitHub Desktop.
Save mertdotcc/094152607b09b42e4a6d88fa4e53a7b4 to your computer and use it in GitHub Desktop.
class Student():
def __init__(self, first_name, last_name, birth_year, emergency_contact):
self.first_name = first_name
self.last_name = last_name
self.birth_year = birth_year
self.emergency_contact = emergency_contact
@classmethod
def from_string(cls, student_string):
first_name, last_name, birth_year, emergency_contact = student_string.split("-")
return cls(first_name, last_name, birth_year, emergency_contact)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment