Pointers
Justin Sheehy
dworkin at ccs.neu.edu
Fri Mar 17 15:26:06 EST 2000
More information about the Python-list mailing list
Fri Mar 17 15:26:06 EST 2000
- Previous message (by thread): Pointers
- Next message (by thread): Pointers
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Curtis Jensen <cjensen at bioeng.ucsd.edu> writes: > If the data in the dictionary changes, I want the data in the class to > automaticaly change also. Is this possible? Is there a reason why you can't just contain a reference to the dictionary in the class? An example that is probably not sufficient for your needs but that illustrates my point: class with_d: def __init__(self, d): self.d = d You could then do things like: >>> d = {} >>> d['A'] = 1 >>> d['B'] = 0 >>> a = with_d(d) >>> d['B'] = 2 >>> a.d['A'] 1 >>> a.d['B'] 2 >>> b = with_d(d) >>> b.d['A'] = 3 >>> a.d['A'] 3 >>> You could employ various bits of trickery to make this prettier; I am only trying to demonstrate the general idea. -Justin
- Previous message (by thread): Pointers
- Next message (by thread): Pointers
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list