Hi!

When one uses ClasscallMetaclass for a class C and then defines a static method
C.__classcall__, then creation of instances of C is done by this __classcall__.
I just noticed that it is even possible that the resulting instances are
not necessarily instances of C:

  sage: from sage.misc.classcall_metaclass import ClasscallMetaclass
  sage: class A:
  ....:     def __init__(self, n):
  ....:         self.n = n
  ....:     def __repr__(self):
  ....:         return "A(%s)"%self.n
  ....:     
  sage: class C:
  ....:     __metaclass__ = ClasscallMetaclass
  ....:     @staticmethod
  ....:     def __classcall__(cls, *args, **kwds):
  ....:         return A(*args, **kwds)
  ....:     
  sage: C(4)
  A(4)
  sage: isinstance(_,C)
  False

Do we want such a behaviour? Or should ClasscallMetaclass.__call__ do
some assertion that makes sure that it can only return instances of the
class in question?

Best regards,
Simon


-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to