self

holger krekel pyth at devel.trillke.net
Wed Jun 5 20:41:12 EDT 2002


David Bolen wrote:
> [me]
> > everything is a google-search away if you know the right codewords :-)
> > I don't in this case, though ...
> 
> Sorry, I must admit to being temporarily overcome with a fit of laziness.  I
> had actually fumbled around a bit before finding the posts I mentioned, so I
> should really have tried to include a reference.
> 
> Lest the codewords remain secret, I managed to wind my way there with a
> search on "eval dictionary instance" in comp.lang.python (which referenced a
> post of Tim's on the fourth page of results).
> 
> The messages I had found occurred deep into a "Dictionary from list?" thread
> from last October which crossed over into the subject of subclassing
> dictionaries:
> 
> http://groups.google.com/groups?th=2338421ec8397bec&seekm=mailman.1004338951
> .27778.python-list%40python.org

very nice, thanks!

[GvR in the above link]
  IMO, fixing these internal accesses to always use the overrides would
  remove much of the attractiveness of subclassing built-in types; I
  believe it would slow things down too much given the current state of
  the implementation.

  If you want a vaguely dictionary-like object, write a class that
  doesn't derive from dictionary but implements the mapping protocol; if
  you want a base class that implements most of the operations already,
  start with UserDict.

This seems reasonable except that 'exec' and 'eval' require a real dict-type.
Due to the generic nature of these execution statements i guess that
fixing it is roughly equivalent to fixing it all over the place unless
they could be somehow special-cased. Oh well...

  holger





More information about the Python-list mailing list