Loading ...
Sorry, an error occurred while loading the content.

192Re: [python-iter] Questioning the problem... how about __queryinterface__ ?

Expand Messages
  • Clark C. Evans
    Mar 16, 2001
      This previous proposal was kinda brain dead, as it
      requires the introduction of a "interface" type
      which is "not pythonic".

      However, I was wondering. Assume the following:

      a) Add a __queryinterface__ slot (in lieu of a __iter__ slot)

      b) __queryinterface__ a string which uniquely identifies the
      interface and returns an object which implements the interface
      (what is an interface is left vague) or an InterfaceUnknown

      c) Revise the iterator proposal, so that all calls to
      is replaced with

      d) Revise the iterator proposal, so that implementsion of
      __iter__ change from:

      def __iter__()
      return self


      def __queryinterface__(interface)
      if interface = "org.python.iterator": return self
      raise InterfaceUnknown


      If we are going to add a slot to support "iterator interfaces",
      why not make it generic to support any type of interface?


      P.S. This does not change the semantics of the
      __iter__ proposal much at all...
    • Show all 4 messages in this topic