I just started programming and I am learning Python using A Byte of Python. I am having a problem with the modules chapter. I don't really understand modules very well, so maybe this is a dumb question, but I copied and pasted the input and it returned a different output. The input that he suggests is
import sys
print('The command line arguments are:')
for i in sys.argv:
print i
print '\n\nThe PYTHONPATH is', sys.path, '\n'
and this is the output:
$ python module_using_sys.py we are arguments
The command line arguments are:
module_using_sys.py
we
are
arguments
The PYTHONPATH is ['/tmp/py',
# many entries here, not shown here
'/Library/Python/2.7/site-packages',
'/usr/local/lib/python2.7/site-packages']
However my output using the same input is different. Here it is:
pedro@pedro-Inspiron-3521:~/Desktop/python$ python modulo1.py
The command line arguments are:
modulo1.py
The PYTHONPATH is ['/home/pedro/Desktop/python', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
I understand that when you write import sys you are making the built in module that as things related to the system available for use. I also know that the for looping statement iterates over a sequence, and the sequence in this case should be the command line arguments that exist. However, it just appears modulo1.py, which is the name of the file where i saved the code i copied and pasted. I don't really understand the pythonpath thing, but according to my research it is the list of directories where potentially exist modules. I use gedit as text editor and ubuntu as os and ubuntu's terminal. What did I do wrong?