another problem with modules

Discussion in 'Python' started by Tim Hanson, Feb 17, 2011.

  1. Tim Hanson

    Tim Hanson Guest

    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?
     
    Tim Hanson, Feb 17, 2011
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Remy Cool
    Replies:
    1
    Views:
    438
    Remy Cool
    Aug 27, 2003
  2. Tobiah
    Replies:
    2
    Views:
    320
    Tobiah
    Sep 14, 2003
  3. Ben Weintraub

    Disabling modules using Modules/Setup

    Ben Weintraub, Sep 9, 2006, in forum: Python
    Replies:
    0
    Views:
    359
    Ben Weintraub
    Sep 9, 2006
  4. Peter Peyman Puk

    Importing v reloading modules modules

    Peter Peyman Puk, Mar 19, 2010, in forum: Python
    Replies:
    0
    Views:
    310
    Peter Peyman Puk
    Mar 19, 2010
  5. ImpalerCore
    Replies:
    0
    Views:
    869
    ImpalerCore
    Mar 10, 2011
Loading...

Share This Page