Commonly-used names in the Python standard library

Marko Rauhamaa marko at pacujo.net
Fri Feb 21 02:21:56 EST 2014


Steven D'Aprano <steve+comp.lang.python at pearwood.info>:

> On Thu, 20 Feb 2014 12:22:29 +0200, Marko Rauhamaa wrote:
>> I'm looking forward to the day when every application can add its own
>> keywords as is customary in Lisp.
>
> And what a wonderful day that will be! Reading any piece of code you
> didn't write yourself -- or wrote a long time ago -- will be an
> adventure! Every script will have it's own exciting new set of
> keywords doing who knows what, which makes every script nearly it's
> own language! Oh joy, I cannot wait!
>
> That's sarcasm, by the way.

I don't hear Lispers or C programmers complaining. Yes, you can shoot
yourself in the foot with macro trickery, but macros can greatly enhance
code readability and remove the need for code generators. That's why
they are used extensively in Linux kernel code and GOOPS (Guile's object
system), for example.

>> One advantage of Perl is that names and keywords are in separate
>> namespaces so introducing new keywords is easy.
>
> 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.

Perl does that by forcing you to prefix you variables with $ et al. The
analogy would be:

for $for in @in:
    while $while:
        if $if:
            raise $raise

I'm not saying I like the look of that, but it does have a distinct
advantage in introducing new keywords.


Marko



More information about the Python-list mailing list