syntax for code blocks

Ben Finney ben+python at benfinney.id.au
Sun Apr 29 23:30:56 EDT 2012


Peter Pearson <ppearson at nowhere.invalid> writes:

> On Fri, 27 Apr 2012 13:24:35 +0200, Kiuhnm <kiuhnm03.4t.yahoo.it> wrote:

> > I'd like to change the syntax of my module 'codeblocks' to make it
> > more pythonic.

The “chained callable” style isn't very Pythonic, IMO. Even worse is the
penchant for ‘foo .bar()’, the space obscures the fact that this is
attribute access.

Far from Pythonic, this seems to be an attempt to write some other
language in Python code.

> > Current Syntax:
> >
> >      with res << func(arg1) << 'x, y':
> >          print(x, y)
> >
> >      with res << func(arg1) << block_name << 'x, y':
> >          print(x, y)
> >
> > New Syntax:
> >
> >      with res == func(arg1) .taking_block (x, y):
> >          print(x, y)
> >
> >      with res == func(arg1) .taking_block (x, y) as block_name:
> >          print(x, y)
> [snip]
>
> Hey, guys, am I the only one here who can't even guess what
> this code does?  When did Python become so obscure?

No, you're not alone; I think that code is pretty poor at communicating
the intent.

AFAICT the above code is a proposal. I don't know who (other than the
original poster) thinks it's any good.

-- 
 \       “I cannot be angry at God, in whom I do not believe.” —Simone |
  `\                                                       De Beauvoir |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list