Is there a reference/alias/pointer in Python?

James Henderson james at logicalprogression.net
Fri Jul 23 04:03:08 CEST 2004


James Henderson wrote:

> If you really want CurrentUser to appear as an attribute (data member) 
> you could make it a descriptor.  Something like:
> 
> class UserOptionsClass:
>     def __init__(self, currentUser):
>         self.Users = {'current_users_username': currentUser}
>     def getCurrentUser(self):
>          return self.Users['current_users_username']
>     def setCurrentUser(self, name):
>          self.Users['current_users_username'] = name
>     CurrentUser = property(getCurrentUser, setCurrentUser)

If you find that doesn't work try putting "(object)" after 
"UserOptionsClass" (grins sheepishly).  J.





More information about the Python-list mailing list