How to build Hierarchies of dict's? (Prototypes in Python?)

Larry Bates lbates at websafe.com
Fri Feb 23 18:44:14 EST 2007


Charles D Hixson wrote:
> I'm sure I've read before about how to construct prototypes in Python,
> but I haven't been able to track it down (or figure it out).
> 
> What I basically want is a kind of class that has both class and
> instance level dict variables, such that descendant classes
> automatically create their own class and instance level dict variables. 
> The idea is that if a member of this hierarchy looks up something in
> it's local dict, and doesn't find it, it then looks in the class dict,
> and if not there it looks in its ancestral dict's.  This is rather like
> what Python does at compile time, but I want to do it at run time.
> 
> I'm sure I've seen how to do it...but have no idea where, or what it was
> called, or when (probably around the time Prothon was being discussed,
> as I have the idea of prototype associated with it for no clear reason).

What you describe is exactly how Zope works so you might want to spend
some time looking at it.

http://www.zope.org

-Larry



More information about the Python-list mailing list