Importing Definitions

Peter Otten __peter__ at web.de
Thu Sep 5 09:00:13 EDT 2013


Azureaus wrote:

> This will throw an error saying "global name 'A' is not defined."
> 
> Now I know if there was a method I wanted to reference I could do
> something like this in module2. 

> from module1 import method1

What a crazy idea! How could anyone ever think of that!
 
> which would mean from that point on I could just reference it as method1
> rather than module1.method1, is there such a way I could do this with
> definitions??

Please read the tutorial, especially

http://docs.python.org/2/tutorial/modules.html#more-on-modules

before you come up with more crazy shit like this ;)




More information about the Python-list mailing list