[Tutor] importing constants

alan.gauld@bt.com alan.gauld@bt.com
Tue Feb 11 19:01:36 2003


> OTOH if you
> from constants import *
> then just use the constant name.
> 
> Great Idea! I finally see a great reason to use from x import * as all
> constants across the modules will have the same name 

But the usual caveats apply. If you pick a constant name thats already 
in use you get a name collision. However being all uppercase lessens 
the risk somewhat - except that Python library constants are also 
uppercase...

Personally I'd recommend sticking to 

import constants

x = constants.FOO

It keeps things clearer.

Alan G