Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Python help. 3.2 Newbie question?

My first programming language. Getting stuck at loading modules in 3.2. I saved my .py files on my desktop and when I try to load them by using reload(xxx) or import xxx I only get errors. I know that I am not doing something right... Please help. Do I need to save my programs in a specific file for them to load as modules or what? Do I need to specify the path somehow??

3 Answers

Relevance
  • 1 decade ago
    Favorite Answer

    python always imports its modules from a list of directories, depending on operating system

    Always included in this is the current directory, meaning if you started python.exe which in 3.2 would probably be found in C:\Python32, then it would also look in C:\Python32

    If you start python in the command prompt, the current directory is whatever directory you're in before you call the python command

    To check for the path python uses to search for it's modules:

    >>> import sys

    >>> sys.path

    You can then add your own directories where you're own modules are by:

    >>> sys.path.append("myowndirectory")

    also make sure it's the absolute path

  • ?
    Lv 4
    4 years ago

    Do you mean to print them or to establish a three-d array? To print: i = 0; together as i < 4: print(listOne[i], " ", listTwo[i], "n"); i++; ---- i will start at 0 and develop via a million each and every time the loop repeats; it is going to injury the loop whilst it hits 4. each and every time it is going for the time of the loop, it is going to print out the string it incredibly is placed at listOne[besides the fact that i is] then an area, then the string it incredibly is placed at listTwo[besides the fact that i is], then it will make a clean line.--- For setting up a three-d checklist i think it may be: aList[][] = [ ["canine","water"], ["mouse", "field"], ["cat","letter"] ,["giraffe","e book"] ]; And to get admission to, case in point, "mouse", you're able to say aList[a million][a million] --- the 1st block would be in the region 0; the strings interior that block would have their own region (0 and a million to that end). same is going for the rest.------ --------------------------------------... i haven't achieved any Python for a together as so the syntax may be slightly off on the two, yet you will desire to get the belief. in case you could, use a for loop rather of a together as (I forgot the thank you to do it in Python lol). wish I helped.

  • Anonymous
    1 decade ago

    I would try checking your syntax, that's usually the problem for me.

    Also, i find python 2.7 much easier.

    Source(s): Experience www.python.org
Still have questions? Get your answers by asking now.