[Tutor] dictionaries in classes

Luke Jordan luke.jordan at gmail.com
Fri Oct 14 21:35:45 CEST 2005

 Another stumped beginner here.
 I'm trying to have functions to create, edit and store dictionaries within
a class. What I can't figure out is how to retain the edits after making
them. I think it has something to do with namespace. Ideally I'd like to
pickle class instances and be able to access each instance's unique
dictionaries through a classInst.dict arrangement. I don't know why I can't
figure out how to make the dictionary an attribute of the class, or if
that's even possible. Does the dict have to be a separate pickled file?
 I've tried setting the dict in these namespaces:
 class N:
 dict = {}
 class N:
 def func(self):
 dict = {}
 but neither of these is working for me. If I make the dict global, then all
class instances could edit it, which is not what I'm shooting for either.
I'm out of ideas, and I sense that there is something basic that I either
don't know or am overlooking.
 Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20051014/2129b6f8/attachment.htm

More information about the Tutor mailing list