#9468: Extend ClasscallMetaclass to allow for membership testing
---------------------------------+------------------------------------------
   Reporter:  nthiery            |       Owner:  jason   
       Type:  enhancement        |      Status:  new     
   Priority:  major              |   Milestone:  sage-4.5
  Component:  misc               |    Keywords:          
     Author:  Nicolas M. ThiƩry  |    Upstream:  N/A     
   Reviewer:  Florent Hivert     |      Merged:          
Work_issues:                     |  
---------------------------------+------------------------------------------
 From the doc:
 {{{
         Let ``cls`` be a class in :class:`ClasscallMetaclass`, and
 consider
         a call of the form:

             ``x in cls``

         If ``cls`` defines a method ``__classcontains__``, then this
         results in a call to::

          - ``cls.__classcontains__(cls, x)``

         EXAMPLES:

         We construct a class which implements membership testing, and
         which contains ``1`` and no other x::

             sage: from sage.misc.classcall_metaclass import
 ClasscallMetaclass
             sage: class Foo(object):
             ...       __metaclass__ = ClasscallMetaclass
             ...       @staticmethod
             ...       def __classcontains__(cls, x):
             ...           return x == 1
             sage: 1 in Foo
             True
             sage: 2 in Foo
             False
 }}}

 This patch also fixes some typos and such in the documentation of
 ClassCallMetaclass

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9468>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to