Newbie Using "Programming Python" 1st Ed. Question

mowestusa justnotworking at mail.com
Mon Dec 16 11:35:25 EST 2002


I hope you can help.  I only have experience programming macros in Word,
WordPerfect, NoteTab, and some Batch File stuff.  So I'm learning computer
programming from scratch.

I have gone through the "Learning Python for Beginners" and the tutorial at
the end of "Programming Python", but neither of those explain why I'm
getting this error.  I'm doing the example in chapter 4 of the "pack1.py"
and "unpack1.py".

I'm getting this error message:
C:\MyTemp\test1>python pack1.py *.py > upload.txt

Traceback (most recent call last):
  File "pack1.py", line 9, in ?
    input = open(name, 'r')
IOError: [Errno 2] No such file or directory: '*.py'

Now I know that it must be having trouble with the * but I don't understand
why.  This is exactly how Mark Lutz tells you to write out the command on
the command line.  You can use * all the time on the command line and MS-DOS
knows what you want.

Here is the pack1.py script:

#1/usr/local/bin/python

import sys
#load the system module
marker = ':::::'

for name in sys.argv[1:]:
     #for all command arguments
     input = open(name, 'r')
     #open the next input file
     print marker + name
     #write a separator line
     print input.read(),
     #and write the file's contents

I think my problem is not understanding what is happening with the sys.argv
command.  I will admit that I'm a little confused because "Programming
Python" seems to be written with the Linux programmer in mind then me, the
Windows 98se dummy.

Thank you for your help.

mowestusa





More information about the Python-list mailing list