[Python-Dev] PEP 340 -- loose ends

Ka-Ping Yee python-dev at zesty.ca
Wed May 4 21:42:50 CEST 2005


Reinhold Birkenfeld wrote:
> There is one problem with using no keyword: You cannot use arbitrary
> expressions in the new statement.
[...]
> resource = opening("file.txt")
> resource:
>     (...)
>
> The latter would have to be forbidden.

Noam Raphael wrote:
> Can you explain why it would have to be forbidden please?

Reinhold Birkenfeld wrote:
> Well, with it you could create suites with _any_ introducing
> identifier. Consider:
>
> with:
>     (...)
>
> synchronized:
>     (...)
>
> try:
>     (...)
>
> transaction:
>     (...)
>
> Do you understand my concern? It would be very, very hard to discern
> these "user-defined statements" from real language constructs.

I think part of the debate is about whether that's good or bad.
I happen to agree with you -- i think a keyword is necessary --
but i believe some people see an advantage in having the flexibility
to make a "real-looking" construct.

As i see it the argument boils down to: Python is not Lisp.

There are good reasons why the language has keywords, why it
distinguishes statements from expressions, uses indentation, and
so on.  All of these properties cause Python programs to be made
of familiar and easily recognizable patterns instead of degenerating
into a homogeneous pile of syntax.


-- ?!ng


More information about the Python-Dev mailing list