Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data = {
- "name": "deep",
- "age": 21,
- "roll_no": 114
- }
- class Student:
- def __init__(self,name,age,roll_no):
- self.name = name
- self.age = age
- self.roll_no = roll_no
- @classmethod
- def from_dicts(cls, data):
- students = []
- for row in data:
- student = cls(row['name'], row['age'], row['roll_no'])
- students.append(student)
- return students
Add Comment
Please, Sign In to add comment