meta-class troubles
Ethan Furman
ethan at stoneleaf.us
Mon Aug 30 10:10:49 EDT 2010
Good Day!
I am stuck... hopefully a few fresh pairs of eyes will spot what I am
missing.
I have a metaclass, Traits, and two different testing files,
test_traits.py and tests.py. test_traits works fine, tests generates
the following error:
C:\Python31\Lib\site-packages\traits\tests>\python31\python tests.py
Traceback (most recent call last):
File "tests.py", line 4, in <module>
class TraitConflict(meta=Traits, traits=(BoxPrint, BigBoxPrint)):
TypeError: type() takes 1 or 3 arguments
Working code from test_traits.py:
class DerivedClass(metaclass=Traits, traits=(TBundle1, TBundle2)):
def repeat(yo, text, count):
print('whatever...')
def whatsit(yo, arg1):
print("calling baseclass's whatsit...")
print(super().whatsit(arg1))
Failing code from tests.py:
class TraitConflict(meta=Traits, traits=(BoxPrint, BigBoxPrint)):
def useless(yo):
print("this class won't compile")
Any clues or pointers *greatly* appreciated!
~Ethan~
--
Traits is homegrown, the idea based on Michele Simionato's Simple Traits
experiment. It was intrigueing, and I wanted to see if I could
implement something similar in Python 3. Any ideas now on what to do
with it will also be greatly appreciated! :)
More information about the Python-list
mailing list