[EMAIL PROTECTED] wrote:
> Hi,  why does
> 
>>>> import compiler
>>>> compileFile("foo.py")
> 
> complain name 'compileFile' not defined.  

Probably because it's not ?

import <modulename> imports the name <modulename> in the current
namespace. Then <modulename> let you access all the names defined in
<modulename> namespace. So in you're case, it should be:

>>>> import compiler
>>>> compiler.compileFile("foo.py")


> But
> 
>>> >from compiler import *
> 
> works. 

"from <modulename> import <somename>" directly loads <somename> into the
current namespace. The 'import *' loads all public names from
<modulename>.  And FWIW it's usually considered bad style (potential
name clash, and can makes hard to tell where a name is defined...)

HTH
-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to