I have a class like this:
class User:
def __init__(self, uid):
userinfo = json.load(urlopen(passportapi + 'user/' + uid))
This class would load user information from a remote api and set corresponding attributes for this class so I can access these attributes by:
print user.username
print user.group_id
Is there any way to implement this? Thanks
print vars(user)['username']You can replace 'username' with the name of any attribute you want to access