[Zope3-checkins] CVS: Zope3/src/zope/proxy/context/tests - test_wrapper.py:1.4

Guido van Rossum guido@python.org
Wed, 09 Apr 2003 11:34:33 -0400


> > BTW, can't this
> >     t1 = type('ContextUnawareObj', (), {slot: doit})
> > be spelled as
> > 
> > class ContextUnawareObj(object):
> >     slot = doit
> 
> No. That would be:
> 
>    t1 = type('ContextUnawareObj', (), {'slot': doit})

Very subtle!

I'd suggest this:

  class ContextUnawareObj(object):
    pass
  setattr(ContextUnawareObj, slot, doit)

The 3-arg type(...) call is very uncommon (except among
meta-programmers :-) and many people would not know what it does.  The
class statement + setattr() call is pretty obvious.

--Guido van Rossum (home page: http://www.python.org/~guido/)