meta-class troubles
Xavier Ho
contact at xavierho.com
Mon Aug 30 10:16:55 EDT 2010
Ethan, are you trying to write the constructor in the class statement?
Cheers,
Xav
On 31 August 2010 00:10, Ethan Furman <ethan at stoneleaf.us> wrote:
> 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! :)
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100831/2852d6bc/attachment-0001.html>
More information about the Python-list
mailing list