type = "instance" instead of "dict"

Steve Juranich sjuranic at gmail.com
Mon Feb 27 18:17:11 EST 2006


Cruella DeVille wrote:

> I created a class Dict (not dict), but since it only complicates things
> for me I implemented my program without it.
> 
> when I wrote myDictionary = dictionary.__dict__.iteritems() it worked
> better...
> what does the __dict__ mean?

This is something else entirely and almost *certainly* not what you want. 
Here's the skinny on how to subclass the built-in `dict' type.

class Dict(dict):
  # Your mods go here.

>From your earlier posts, it sounds like you've managed to get a
"classic" (i.e., old, almost deprecated) class.  Change your class
definition to look more like what I have above and things should start
working.

If you're willing to post the code, we could pinpoint the problems much
faster.

-- 
Steve Juranich
Tucson, AZ
USA




More information about the Python-list mailing list