i can`t get python working on the command line (linux)

Mark markg85 at gmail.com
Tue Mar 13 11:04:05 EDT 2007


Hey,

first of all: sorry for the 100% n00b question
i`m brand new to python and i seem to start off with the biggest problem of
all.. not even getting python to work.
i`m running Fedora core 7 test 2 and all the python based applications are
working fine (like pirut, pipet, and some other yum related tools)

but when i try to run this script:

#!/usr/bin/python
#
# python script tel.py
# gevonden door Jan Mooij 24 september 2000
#
from sys import *
from string import *

     # Create an empty dictionary.
count = {}

for line in open(argv[1], 'r').readlines():
    for word in split(line):
        if count.has_key(word):
            count[word] = count[word] + 1
        else:
            count[word] = 1
words = count.keys()
words.sort()
for word in words:
    print "%15s\t%10d" % (word, count[word])


and i`ve put it in tel.py (just the same as in the sample) than chmod
it to 777 (just to make sure it isn`t a permission issue) and than i
run it with: ./tel.py
now this is the error that i get:

Traceback (most recent call last):
  File "./tel.py", line 12, in <module>
    for line in open(argv[1], 'r').readlines():
IndexError: list index out of range

also i`m not even getting the most simple sample code to work.. "Hello World".
everything works fine when i first enter the python console by typing
python. than i have the  >>> things
than print "Hello World" gives me the expected result but that`s not
what i want.. i want to do it from a file..

the solution is probable extremely simple but i have no idea as a
complete n00b in python. i do have alot php experience.
hope someone could help me out with this.

o and any function that i use in python gives me "command not found:
print/whatever function i use"
(probable just a simple yum install command that i need to do to get
this working.. just try to figure that out with no python knowledge)

Thanx alot in favor.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070313/06a46911/attachment.html>


More information about the Python-list mailing list