when is a != foo.a?
Duncan Booth
duncan.booth at invalid.invalid
Mon Aug 28 07:44:29 EDT 2006
More information about the Python-list mailing list
Mon Aug 28 07:44:29 EDT 2006
- Previous message (by thread): Learning Python - Have Question.
- Next message (by thread): when is a != foo.a?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Chaz Ginger wrote: > Can someone explain what is really going on here? Think of 'from x import y' as an assignment. Roughly equivalent to: y = sys.modules['x'].y (except of course you don't have to have imported sys, and it will load the module 'x' if it hasn't already been imported.) > b.py ---------------------- > > from a import foo In other words: foo = a.foo foo in module b is initialised from a.foo, but it is a separate variable. So when a.foo is rebound that doesn't affect b.foo. > def b(): print foo > > c.py ---------------------- > > import a > from b import b and here: b = b.b > > print 'per a.a() ',a.foo > a.a(245) > print 'expect 245 ', a.foo > b() >
- Previous message (by thread): Learning Python - Have Question.
- Next message (by thread): when is a != foo.a?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list