Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
> FWIW, the equivalent in idiomatic Python3 is:

Thanks, interesting idea to turn it inside out! =)

But why Python3, AFAIK generators were already introduced in 2.

> while back a monstrosity was released...

Thanks, even more fun! =)

Especially the last line (after "bugs and limitations")

Oh, and almost forgot: We are sorry, Guido. So sorry.

Grin! xD

Cheers Rolf

( addicted to the Perl Programming Language)


) while its a bit cumbersome that you need to iterate over the yields... ... why not using a decorator to abstract the loop away?


this worked for me in Py 2.5.2

>>> def test(): ... print("You are in the method") ... yield 1 ... print("You are again back to the method") ... yield 2 ... >>> for a in test(): ... print("You are in the block "+str(a)) ... You are in the method You are in the block 1 You are again back to the method You are in the block 2

In reply to Re^4: RFC: Simulating Ruby's "yield" and "blocks" in Perl (Python) by LanX
in thread RFC: Simulating Ruby's "yield" and "blocks" in Perl by LanX

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (6)
    As of 2018-08-14 17:27 GMT
    Find Nodes?
      Voting Booth?
      Asked to put a square peg in a round hole, I would:

      Results (153 votes). Check out past polls.