another problem with modules

T

Tim Hanson

Okay, I solved my problem with Python finding modules:

I put the following into a file in my home directory, on the good advice of
Andrea Crotti:

import sys
sys.path.append('/home/foo/mypath'

I named the file "~/pypath.py", so now, in idle:

import pypath

No errors.

I'm still getting a little frustrated loading modules. I typed the following
little test function into idle:

def intersect(seq1,seq2):
res=[]
for x in seq1:
if x in seq2:
res.append(x)
return res

intersect('spam','spmmer')


No big deal. Runs fine. Exited and re-entered idle,

import pypath
import intersect #the name of a file that contains the above short function.
intersect('spam','spmmer')

Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
intersect('spam','spmmer')
TypeError: 'module' object is not callable
Huh? Why doesn't this run when imported? More importantly, how do I
interpret this error message so that I can find the problem myself next time?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top