Hacker News new | ask | show | jobs
by Izkata 2212 days ago
Your example isn't using "y", so you should also be able to drop the " as y" part (unless the AST hack requires it for some reason).

Edit: Oh, nevermind - the "y" is how you access it after the with statement. Weird for python, but it makes sense given the rewritten version. I was thinking your version would have a non-rewritten "result = something" within the with block in a real use, but that's not what it's doing.

1 comments

Heh, yup, it's part of the hackiness of it all. "with do(MyMonadClass) as my_variable: <some code>" equates to haskell's "myVariable = do <some code>". I can't remember why the MyMonadClass part was necessary. Maybe for the mreturn.