Opened 12 years ago

Closed 11 years ago

#9468 closed enhancement (fixed)

Extend ClasscallMetaclass to allow for membership testing

Reported by: nthiery Owned by: jason
Priority: major Milestone: sage-4.7.1
Component: misc Keywords:
Cc: sage-combinat Merged in: sage-4.7.1.alpha3
Authors: Nicolas M. Thiéry Reviewers: Florent Hivert
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

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?

Attachments (1)

trac_9468-classcallmetaclass-classcontains-nt.patch (6.9 KB) - added by nthiery 11 years ago.
Final version including review patch by Florent

Download all attachments as: .zip

Change History (6)

comment:1 Changed 12 years ago by nthiery

  • Status changed from new to needs_review

Florent: the documentation should really include the * methods. Here, this makes the link for get wrongly point to the corresponding Python doc (with the intersphinx option).

comment:2 follow-up: Changed 11 years ago by nthiery

  • Milestone changed from sage-4.7 to sage-4.7.1

comment:3 in reply to: ↑ 2 Changed 11 years ago by hivert

Replying to nthiery:

I just pushed on sage-combinat a trivial doc-fix patch. Otherwise it is ready to go.

Changed 11 years ago by nthiery

Final version including review patch by Florent

comment:4 Changed 11 years ago by nthiery

  • Status changed from needs_review to positive_review

Checked, folded, posted. Thanks!

comment:5 Changed 11 years ago by jdemeyer

  • Merged in set to sage-4.7.1.alpha3
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.