[Tutor] confusion about imports

David Rock david at graniteweb.com
Mon Jul 9 21:26:32 CEST 2012


* Chris Hare <chare at labr.net> [2012-07-09 13:33]:
<snip>
> import functions
> import os
> import db
> 
> when everything was all in one file, that worked just fine.  Now, with it all split up, once I changed
> 
> r = DbPath()
> 
> to
> 
> r = functions.DbPath()
> 
> things seems to work now.  I hope this is it!!!
> 

Yes, that's it.  As mentioned elsewhere, you have to reference the
module name in order to let python know _which_ one you want.

For example, you could have the same DbPath() method in two different
modules: module1 and  module2, so you need to be able to differentiate.

module1.DbPath() is not the same thing as module2.DbPath()

Your functions.DbPath() is the way to go.

-- 
David Rock
david at graniteweb.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20120709/89e4b647/attachment.pgp>


More information about the Tutor mailing list