Results 1 to 2 of 2

Thread: [Python] Importing a module

  1. #1

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Resolved [Python] Importing a module

    I can't find any examples of this in my book. And I am at the moment searching the web. But if anyone knows, how do I import a "module" (file) with my own usefull functions. Something like this didn't work:


    main.py:
    Code:
    import myModule
    
    
    print "Trying to call a function in the other file"
    myFunk()

    myModule.py:
    Code:
    def myFunk():
        print "It worked"


    It says that it can't find the function. Both files are in the same folder. Do I have to write some code to make it a module or something? Or is there a keyword that I have to use to make the function public or something?

    What am I missing here?



    ØØ
    Last edited by NoteMe; May 17th, 2005 at 05:06 AM.

  2. #2

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: [Python] Importing a module

    Ohhhh...I got it...I have to add the modulename in front of it...that sucks...well, at least it is working though...



    ØØ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width