pygame - importing GL - very bad...

someone newsboost at
Wed Jan 2 15:06:57 CET 2013

On 01/02/2013 08:39 AM, Steven D'Aprano wrote:
> On Wed, 02 Jan 2013 00:49:36 +0100, someone wrote:

>> What does this mean? Why does it say 'format" cannot be deleted after I
>> did the wildcard import ?
> It means that there is no "format" in the current scope, which implies
> that pygame no longer has a "format" which can be imported.
> You don't need an import to shadow built-ins. See for example:
> py> format
> <built-in function format>
> py> format = "NOBODY expects the Spanish Inquisition!"
> py> format  # this shadows the built-in "format"
> 'NOBODY expects the Spanish Inquisition!'
> py> del format  # get rid of the Spanish Inquisition
> py> format
> <built-in function format>
> py> del format
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
> NameError: name 'format' is not defined

Ok, thank you very much - that was/is very illustrative...

> When a name is not discovered in the current scope, the builtin scope is
> checked before Python gives up and reports a NameError. But del only
> works on the current scope, to stop you from accidentally deleting the
> wrong object.

Ok, I'll remember that in the future, thank you.

>>   > pylint may still complain, but you can ignore it. By deleting the
>>   > name "format", that will unshadow the builtin format.
>> Are you sure?
> Since it turns out that pylint was actually wrong to complain, no format
> was actually imported, then yes you can safely ignore it :-)

Ok, I can see from your example that you're right. Nice to know the real 
explanation, thank you very much. :-)

More information about the Python-list mailing list