Newbie Problem
rbl at hal.cwru.edu
rbl at hal.cwru.edu
Wed Jul 28 13:16:12 EDT 1999
I'm new to Python, but quite excited about its possiblities. I'm
running on a Mac G3, System 8.6.
There is some Python code I've downloaded that I'm trying to run.
If I just drop the .py file on the Python icon, I get some errors,
so I am trying to run it interactively for debugging.
Here is what happened:
Python 1.5.1 (#37, Apr 27 1998, 13:36:04) [CW PPC w/GUSI w/MSL]
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import sys
>>> import random
>>> import string
>>>
>>> def run(filename=''):
... if filename=='':
File "<stdin>", line 2
if filename=='':
^
SyntaxError: invalid syntax
>>>
The original code segment is:
import sys
import random
import string
def run(filename=''):
if filename=='':
file = open( raw_input('Enter name of a textfile to read: '), 'r')
else:
file = open( filename, 'r')
text = file.read()
file.close()
words = string.split(text)
===
I must be doing something stupid and/or naive.
Advice, please?
Thank you,
Robin Lake
rbl at po.cwru.edu
More information about the Python-list
mailing list