python3: 'where' keyword
carribeiro at gmail.com
Sat Jan 8 23:17:08 CET 2005
On Sat, 08 Jan 2005 12:53:05 -0500, Peter Hansen <peter at engcorp.com> wrote:
> Andrey Tatarinov wrote:
> > >>> print words, words where:
> > >>> words = input.split()
> > - defining variables in "where" block would restrict their visibility to
> > one expression
> Then your example above doesn't work... print takes a
> sequence of expressions, not a tuple as you seem to think.
I found it strange that he had chosen to make the example with
"print", that is a statement. I'm not sure how could it be made to
work with both expressions and statements, it just seems strange...
Overall, I found the idea interesting. It seems like a obvious
counterpart to "with", in the sense that both act as modifiers to the
scoping rules. I think it can be made to work, and that it would lead
to elegant & readable code, but there are still lots of things to
consider: exception handling, fast name lookup in the "where" block,
access to symbols outside the "where" block, just to name a few.
Consultoria em Projetos
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com
More information about the Python-list