[FRPythoneers] Need a Dope Slap

Keith Hellman kehellman at yahoo.com
Wed Feb 20 12:05:44 MST 2002

I always like playing and tinkering with python enough to feel I've
learned (for myself that is) some tasty little nuance in the language.

The downside of course, is that these little morsels tend to whap my
thought-I-understood-python-side-of-brain over to the damn-i-dunno-squat

I used to think that 
	from foo import a, b, c as d
was a way of keeping the global namespace trimmed down - which certainly
sounds like good coding practice.  But apparently it is different than
	import foo
	import foo as f

In that, if I try to use a global flag in foo (suppose a) from another
module and do this:
	a = 0
I don't end up changing the 'a' in foo, just the 'a' in my current module
- not much of a global flag heh?  (Happens with 'from foo import *' also

BUT, if I do either 'import foo' or 'import foo as f', then everything
works as I would expect (using foo.a = 0, f.a = 0...).

If I do
	from foo import a
	import foo
	a = 0
I still don't get global flag features.

So, I appreciate how to make global flags work (at least this way, if
there is a better, please let me know) - what I'm wondering is: are there
other subtle differences between 'import' and 'from * import' that I'm

I did a search in the Python FAQ read all about globals & imports in the
books/docs I have but didn't find any real details.  In fact, one book I
have states that the difference is 'purely syntax' (my words, not theirs).

At any rate, I'm ready for more Dope Splaps, so go-ahead and let me have
it & TIA.

Keith E. Hellman
kehellman at yahoo.com

Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games

More information about the FRPythoneers mailing list