[Tutor] dictionaries in classes

w chun wescpy at gmail.com
Sat Oct 15 00:31:46 CEST 2005


>
> On Fri, 14 Oct 2005, Luke Jordan wrote:
>
> > I'm trying to have functions to create, edit and store dictionaries
> > within a class.



i 2nd danny's motion: make your dictionary an instance attribute (unique to
that instance) rather than a class attribute (shared amongst all instances),
and 2ndly, don't use 'dict' because that is a built-in (factory) function:

class N:
 def __init__(self):
 self.myDict = {}

n = N()

... then pickle 'n' as danny has described.

good luck!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2006,2001
http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com <http://wescpy-at-gmail.com>
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20051014/7fde67d9/attachment.html


More information about the Tutor mailing list