Commonly-used names in the Python standard library

Chris Angelico rosuav at gmail.com
Fri Feb 21 02:10:20 EST 2014


On Fri, Feb 21, 2014 at 5:59 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> Then I can write code like:
>
> for for in in:
>     while while:
>         if if:
>             raise raise
>
> which will go a long way to ensuring that my code is an hostile and
> unreadable as possible.

REXX allows that. Most people wouldn't use classic keywords like 'if',
as that'll only cause confusion (although "if if then then; else else"
is legal), but some of the other keywords are useful in other
contexts. The main advantage is that, for instance, the PARSE command
can freely use keywords:

PARSE VAR x blah blah
PARSE VALUE linein(blah) WITH blah blah

All those words (parse, var, value, with) are keywords - in that
context. But I can happily use "var" and "value" elsewhere, and will
do so. Python, on the other hand, has to be more careful; so you see
things like "cls" instead of "class", or "import_" and so on, with the
trailing underscore.

Trade-offs.

ChrisA



More information about the Python-list mailing list