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

Re: [python-iter] Resolution at Python 9

Expand Messages
  • qrczak@knm.org.pl
    ... You can t have this syntax, because it already means a different thing: unpacking 1-tuples. IMHO having explicit dictionary methods like xkeys and xitems
    Message 1 of 68 , Mar 11, 2001
    • 0 Attachment
      Sun, 11 Mar 2001 06:02:23 -0500 (EST), Clark C. Evans <cce@...> pisze:

      > for (,y) in [ (1,'a'), (2,'b') ]: print y

      You can't have this syntax, because it already means a different thing:
      unpacking 1-tuples.

      IMHO having explicit dictionary methods like xkeys and xitems will
      be enough.

      --
      __("< Marcin Kowalczyk * qrczak@... http://qrczak.ids.net.pl/
      \__/
      ^^ SYGNATURA ZAST─śPCZA
      QRCZAK
    • Guido van Rossum
      ... This is already implemented: look at the Queue module: http://python.sourceforge.net/devel-docs/lib/module-Queue.html To push an item into the Queue, you
      Message 68 of 68 , Mar 16, 2001
      • 0 Attachment
        > I think the closest way to do it in Python is to use threads.
        > A thread-aware queue which is an iterator at one end and a file-like
        > sink at the other, implemented once for all uses. Called Chan in
        > Concurrent Haskell. Should be a nice abstraction. Doesn't require
        > more magic than is already there.
        >
        > Well, so there are three approaches, and the third does fit Python!

        This is already implemented: look at the Queue module:

        http://python.sourceforge.net/devel-docs/lib/module-Queue.html

        To push an item into the Queue, you use q.put(x); to pull the next
        item from it, use x = q.get(). If you want a terminator, all you need
        to do is agree on a sentinel value. If you want an iterator, you can
        use iter(q, sentinel).

        The disadvantage is that it's way slow compared to stackframe-based
        solutions, and that's why it's not commonly used as an alternative for
        push/pull interfaces except where threads are already on the mind of
        the programmer.

        --Guido van Rossum (home page: http://www.python.org/~guido/)
      Your message has been successfully submitted and would be delivered to recipients shortly.