[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: i can`t get python working on the command line (linux)
From: Mark <markg85 () gmail ! com>
Date: 2007-03-13 15:04:05
Message-ID: 6e24a8e80703130804y7a88f1b0wf7ed30e98d6a35f7 () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
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.
[Attachment #5 (text/html)]
Hey,<br><br>first of all: sorry for the 100% n00b question<br>i`m brand new to python \
and i seem to start off with the biggest problem of all.. not even getting python to \
work.<br>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) <br><br>but when i \
try to run this script:<br><pre>#!/usr/bin/python<br>#<br># python script tel.py<br># \
gevonden door Jan Mooij 24 september 2000<br>#<br>from sys import *<br>from string \
import *<br><br> # Create an empty dictionary. <br>count = {}<br><br>for line in \
open(argv[1], 'r').readlines():<br> for word in split(line):<br> if \
count.has_key(word):<br> count[word] = count[word] + 1<br> \
else:<br> count[word] = 1 <br>words = count.keys()<br>words.sort()<br>for \
word in words:<br> print "%15s\t%10d" % (word, count[word])<br><br><font \
size="4"><br></font><font style="font-family: arial,sans-serif;" size="4">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<br>now this is the \
error that i get:<br><br>Traceback (most recent call last):<br> File \
"./tel.py", line 12, in <module><br> for line in open(argv[1], \
'r').readlines():<br>IndexError: list index out of range<br><br>also i`m not \
even getting the most simple sample code to work.. "Hello World". \
<br>everything works fine when i first enter the python console by typing python. \
than i have the >>> things<br>than print "Hello World" gives me \
the expected result but that`s not what i want.. i want to do it from a file.. \
<br><br>the solution is probable extremely simple but i have no idea as a complete \
n00b in python. i do have alot php experience.<br>hope someone could help me out with \
this.<br><br>o and any function that i use in python gives me "command not \
found: print/whatever function i use" <br>(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)<br><br>Thanx alot in favor.<br></font></pre>
--
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic