Metaclasses broke in 2.2?

Drew Csillag drew_csillag at geocities.com
Tue Aug 14 10:56:19 EDT 2001


On Tue, Aug 14, 2001 at 03:41:31AM +0000, Guido van Rossum wrote:
> Drew Csillag <drew_csillag at geocities.com> writes:
> 
> > I don't know if this was intended, but it appears that the metaclass
> > instantiation doesn't work with Python 2.2a1.  Are the old metaclass
> > things no longer supported in 2.2 or is it just temporarily broken?
> 
> Can you be more specific?  What old metaclass are you referring to?
> It's probably broken because I changed the Don Beaudry hook invocation
> to favor the new metaclass mechanism that is central to the new types
> in 2.2.

Take any of the code in Demo/metaclasses in 2.2a1.  You get tracebacks
of the variety:

Traceback (most recent call last):
  File "Eiffel.py", line 113, in ?
    _test()
  File "Eiffel.py", line 101, in _test
    class C(Eiffel):
TypeError: cannot create 'instance' instances
drew:~/build/Python-2.2a1/Demo/metaclasses>../../python Enum.py 
Traceback (most recent call last):
  File "Enum.py", line 169, in ?
    _test()
  File "Enum.py", line 128, in _test
    class Color(Enum):
TypeError: cannot create 'instance' instances
drew:~/build/Python-2.2a1/Demo/metaclasses>

I guess the real question is: "how does one go about writing metaclasses
in Python code in 2.2?"

Thanks,
Drew

-- 
print(lambda(m,d,y):['Sun','Mon','Tues','Wed','Thurs','Fri','Satur'][(
lambda(m,d,y):(23*m/9+d+4+y/4-y/100+y/400)%7)(m<3and(m,d+y,y-1)or(m,
d+(y-2),y))])(map(int,raw_input('mm/dd/yyyy>').split('/')))+'day'




More information about the Python-list mailing list