Question:
Python help. 3.2 Newbie question?
TeeHee
2011-04-11 18:18:55 UTC
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??
Three answers:
yz
2011-04-12 02:49:05 UTC
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
?
2017-01-15 12:38:18 UTC
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.
2011-04-11 18:28:55 UTC
I would try checking your syntax, that's usually the problem for me.

Also, i find python 2.7 much easier.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...