syntax for code blocks

Prasad, Ramit ramit.prasad at jpmorgan.com
Wed May 2 13:20:01 EDT 2012


Steven D'Aprano wrote: 
> >> Have you actually tried to use these code blocks of yours? I asked you
> >> for a *working* example earlier, and you replied with examples that
> >> failed with multiple NameErrors and no hint as to how to fix them. And
> >> now you give an example that fails with SyntaxError.
> >
> > The examples I gave you work perfectly.
> 
> Except they don't.
> 
> Look, this isn't difficult. I asked for *working* examples, you gave
> examples that give NameError. Some of those errors are easy to fix, e.g.
> by importing the random and re modules. Some of them aren't. 

[snip] 

> 
> > It's clear that you don't even
> > have the vaguest idea of how my module works or, otherwise, you'd know
> > what you're doing wrong.
> 
> Well duh. What module? Where do I find it? 

[snip part deux]

> Whatever man. It's no skin off my nose. I've tried really hard to give
> your proposal a fair go, but my care factor is rapidly running out if you
> can't even be bothered to ensure your examples use legal Python syntax.


I think the crucial link that was provided in another thread (and
should have been included in a new thread on the same project) is
http://mtomassoli.wordpress.com/2012/04/20/code-blocks-in-python/

The only example I see on that page (for running from module) that 
looks fully complete is:

import codeblocks
codeblocks.rewrite()
def each(iterable, block):
    for e in iterable:
        block(e)                        # step into -> 6:
with each(range(0, 10)) << 'x':
    print('element ' + str(x))
codeblocks.end_of_module()



I have not tried this (or any) example. To me it seems like an 
overly complicated way to avoid creating a function def. Especially
since it creates a function anyway (whether anonymous or named).


Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  



More information about the Python-list mailing list