Commonly-used names in the Python standard library

Chris Angelico rosuav at gmail.com
Thu Feb 20 06:47:29 EST 2014


On Thu, Feb 20, 2014 at 10:28 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Chris Angelico <rosuav at gmail.com>:
>
>> On Thu, Feb 20, 2014 at 9:22 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
>>>   py35.unless x > 7:
>>>       return
>>
>> What about return? Are you allowed to namespace that? And 'from' and
>> 'import' and '*'?
>
> Old keywords are guaranteed not to clash with programs. Introducing new
> keywords runs that risk. Hence, C had to introduce the ugly _Bool
> keyword.

Okay, so what you're saying is that there are three states:

Before Python X.Y, the unless keyword simply doesn't exist. (It can't
be coded in as a module, so it can't exist until someone implements
the code.)

>From X.Y, it can be called up by importing it from "pyAB" and used in
its namespace.

>From A.B onward, it always exists.

Python has a facility like this. It doesn't namespace the keywords,
but it does let you choose whether to have them or not. In Python 2.5,
you could type "from __future__ import with_statement" to turn 'with'
into a keyword. After Python 2.6, it's always a keyword.

ChrisA



More information about the Python-list mailing list