Learning python and the author did not show the part of printing the output of Class method. The author only wanted to demonstrate where we can use Map function.
But I'm trying to figure out how to print what it has returned.
class User:
def __init__(self, username, password):
self.username = username
self.password = password
@classmethod
def from_dict(cls, data):
return cls(data['username'], data['password'])
users = [
{ 'username': 'rolf', 'password': '123'},
{ 'username': 'teclado', 'password': '1234'}
]
user = [User.from_dict(user) for user in users]
print(user)
OR printing this to terminal
user = map(User.from_dict, users)
print(user)
It prints a reference. I want to see the data actually.
[<__main__.User object at 0x7f54b5e02b80>, <__main__.User object at 0x7f54b5e02d00>]
<map object at 0x7f54b5e02d60>