["Followup-To:" nach gmane.comp.mathematics.sage.devel gesetzt.] On 2016-10-11, Simon King <simon.k...@uni-jena.de> wrote: > Hi Jeroen, > > On 2016-10-10, Jeroen Demeyer <jdeme...@cage.ugent.be> wrote: >> Maybe I'm misunderstanding you, but what I wanted to say is: Python 3 >> doesn't have any place to hook a custom metaclass. > > Is there a way to have a metaclass similar to our ClasscallMetaclass at > all, in Python3?? I just tested, having > > class Classcall(type): > def __call__(cls, *args, **opts): > try: > classcall = cls.__classcall__ > except AttributeError: > return type.__call__(cls, *args, **opts) > return classcall(cls, *args, **opts) > > class MyUniqueRepresentation: > __metaclass__ = Classcall
Found it! In Python3, one has to write class MyUniqueRepresentation(metaclass=Classcall): ... and then it works. The same is a syntax error in Python2. Anyway. Since SageMath meanwhile makes use of more and more metaclasses, I created trac ticket #21681 for the introduction of a metaclass framework. Best regards, Simon -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.