Import question

Christopher Subich spam.csubich+block at block.subich.spam.com
Tue Aug 9 21:15:43 EDT 2005


ncf wrote:
> Hmm...thanks for the replies. Judging by this, it looks like I might
> still be in a slight perdiciment with doing it all, but time will tell.
> I wish there were a way I could reference across multiple modules.
> 
> Well, thanks for your help. Hopefully I'll be able to work out some
> *simple* solution for all of this.

What exactly is it that you're trying to do?  You don't need access to 
the class definition (which would be in a module) if you just want to 
manipulate a particular _instance_.  Advantage of dynamic typing and all.

For example:

module1:
def function(x):
    x.method(1)

module2:
class foobar:
    def method(x):
       print 'I received', x, ', aren't I happy?!'

import module1
obj = foobar()
module1.function(obj)



More information about the Python-list mailing list