Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53770
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-09-06 02:10 -0700 |
| References | <28b859f6-f14b-49d2-9e14-5d3febd33441@googlegroups.com> |
| Message-ID | <4a58302f-8b6e-4ba3-92ec-9490b6c98470@googlegroups.com> (permalink) |
| Subject | Re: Importing Definitions |
| From | Azureaus <lo0446@my.bristol.ac.uk> |
Thanks for the advice, much appreciated - I didn't realise you could also import definitions. I do always read the documentation before posting but sometimes I don't know how it's necessarily applicable to my own case sometimes - hence the post. I'll avoid using '*' at all costs, I've had the pleasure of going through lots of Python code recently not written by myself and I can see how that would make it a total nightmare to figure out what was going on. I think Python is awesome and look forward to actually getting good with it. Cheers! On Thursday, 5 September 2013 13:39:37 UTC+1, Azureaus wrote: > Hi all, > > Thank you all for your help so far in the group. > > > > Lets say I have some definitions in a module1.py e.g. > > > > import sys > > A,B,C,D,E = range(5) > > def method1(): > > more code > > end > > > > Then a second module module2.py where I wish to use these definitions > > import module1.py > > print A > > > > 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 > > > > 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?? > > > > Thanks!
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Importing Definitions Azureaus <lo0446@my.bristol.ac.uk> - 2013-09-05 05:39 -0700
Re: Importing Definitions Chris Angelico <rosuav@gmail.com> - 2013-09-05 22:50 +1000
Re: Importing Definitions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-05 17:28 +0000
Re: Importing Definitions Skip Montanaro <skip@pobox.com> - 2013-09-05 13:06 -0500
Re: Importing Definitions Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-09-06 11:05 +0100
Re: Importing Definitions Peter Otten <__peter__@web.de> - 2013-09-05 15:00 +0200
Re: Importing Definitions Ethan Furman <ethan@stoneleaf.us> - 2013-09-05 05:56 -0700
Re: Importing Definitions Azureaus <lo0446@my.bristol.ac.uk> - 2013-09-06 02:10 -0700
csiph-web