On 6 March 2014 11:16, Brian May <[email protected]> wrote: > > > [2] Also, on a separate thread, can somebody point me to a document that > describes the difference between the two forms of import in as described in > [1]? It seems that they are different. >
The best place to find answers for all language questions is the langref. http://docs.python.org/3/reference/simple_stmts.html#the-import-statement specifically, 'import module' loads and initialises the module if needed, and then binds the name 'module' to the module. 'import package.module' loads and initialises package, and then module, if needed. then, it binds the name 'package' to the top-level package. 'from module import name' loads and initialises the module if needed, and then binds the name 'name' to the value of 'module.name'. So the names within the current module are different for the two examples you give - the first binds '__version__' also, and the second binds 'module' also. -- William Leslie Notice: Likely much of this email is, by the nature of copyright, covered under copyright law. You absolutely may reproduce any part of it in accordance with the copyright law of the nation you are reading this in. Any attempt to deny you those rights would be illegal without prior contractual agreement.
_______________________________________________ melbourne-pug mailing list [email protected] https://mail.python.org/mailman/listinfo/melbourne-pug
