Re: [Tutor] Confusion regarding the 'from' statement

2012-08-15 Thread Peter Otten
Mazhar Hussain wrote: > thanks alot for the help, was really confused with this. > Well what ure > trying to say is that even when a module object is deleted from the > global namespace of a module, a reference of it is still present in > the sys.modules dict? Yes, adding the reference to the

Re: [Tutor] Confusion regarding the 'from' statement

2012-08-14 Thread eryksun
On Tue, Aug 14, 2012 at 9:04 PM, Dave Angel wrote: > > 1) recursive imports. If anybody has a non-trivial top-level code, or > even certain class-initialization code, this can cause surprising errors. Yes, it's a problem if you try to "from" import an object that hasn't been defined yet or use

Re: [Tutor] Confusion regarding the 'from' statement

2012-08-14 Thread Dave Angel
On 08/14/2012 04:00 PM, eryksun wrote: > On Tue, Aug 14, 2012 at 2:24 PM, Mazhar Hussain wrote: >> #mod1.py >> from mod2 import test >> test('mod1.py') >> >> #mod2.py >> def countLines(name): >> print len(open(name).readlines()) >> >> def countChars(name): >> print len(open(name).read()) >

Re: [Tutor] Confusion regarding the 'from' statement

2012-08-14 Thread eryksun
On Tue, Aug 14, 2012 at 2:24 PM, Mazhar Hussain wrote: > > #mod1.py > from mod2 import test > test('mod1.py') > > #mod2.py > def countLines(name): > print len(open(name).readlines()) > > def countChars(name): > print len(open(name).read()) > > def test(name): > print 'loading...' >

Re: [Tutor] Confusion regarding the 'from' statement

2012-08-14 Thread Peter Otten
Mazhar Hussain wrote: > Im new to python and theres something thats bothering me for quite a > time. I read in 'Learning Python' by Mark Lutz that when we use a > 'from' statement to import a name present in a module, it first > imports the module then assigns a new name to it(i.e. the name of the

Re: [Tutor] Confusion regarding the 'from' statement

2012-08-14 Thread Joel Goldstick
On Tue, Aug 14, 2012 at 2:43 PM, David Rock wrote: > * Mazhar Hussain [2012-08-14 23:24]: >> the module object with the del statement. However what happens if I >> try to import a name using 'from' that references a name in the >> imported module that itself is not imported. Consider the followin

Re: [Tutor] Confusion regarding the 'from' statement

2012-08-14 Thread David Rock
* Mazhar Hussain [2012-08-14 23:24]: > the module object with the del statement. However what happens if I > try to import a name using 'from' that references a name in the > imported module that itself is not imported. Consider the following > example,here there are two modules mod1.py and mod2.p

[Tutor] Confusion regarding the 'from' statement

2012-08-14 Thread Mazhar Hussain
Im new to python and theres something thats bothering me for quite a time. I read in 'Learning Python' by Mark Lutz that when we use a 'from' statement to import a name present in a module, it first imports the module then assigns a new name to it(i.e. the name of the function,class, etc present in