Wrapping classes

Jeremy Sanders jeremy+complangpython at jeremysanders.net
Fri Sep 23 06:37:30 EDT 2005


Diez B. Roggisch wrote:

> It works - in python 2.4!! I tried subclassing dict, but my
> __getitem__-method wasn't called - most probably because it's a C-type,
> but I don't know for sure. Maybe someone can elaborate on that?

Yes - I tried that (see thread below). Unfortunately it needs Python 2.4,
and I can't rely on my users having that.

Traceback (most recent call last):
  File "test.py", line 15, in ?
    print eval("10 * a + b", globals(), l)
TypeError: eval() argument 3 must be dict, not Foo

If you subclass dict it doesn't call the __getitem__ method.

Jeremy

-- 
Jeremy Sanders
http://www.jeremysanders.net/



More information about the Python-list mailing list