Unexpected python exception

Chris Rebert clp2 at rebertia.com
Wed Nov 11 14:04:57 CET 2009

On Wed, Nov 11, 2009 at 4:37 AM, Richard Purdie <rpurdie at rpsys.net> wrote:
> Is there a way to make the "global x" apply to all functions without
> adding it to each one?

Thankfully, no.

> What I'm trying to do is to avoid having "import X" statements
> everywhere by changing __builtin__. It seems my approach doesn't have
> quite the same effect as a true import though.

And you can't just put all your imports together at the top of the
file because...?
If you're importing the same stuff across multiple modules, I'd say
you have a code smell on your hands. Injecting stuff into the builtin
namespace purely for convenience's sake is Just Evil (tm). At the
least, you can put all the imports in one module and then use `from
all_imports import *`, which is just slightly less evil.


More information about the Python-list mailing list