[Tutor] Example prog

Simon Brunning SBrunning@trisystems.co.uk
Tue, 29 Aug 2000 09:25:07 +0100


Daniel,
I don't think that what you are doing will work under windows. Linux shells
will automagically expand arguments like *.txt, so the python module will
receive a list of files. This doesn't happen under windows, so you'll have
to expand the argument yourself, probably using the glob module. 

See <http://www.oreilly.com/catalog/lpython/chapter/ch09.html> for an
example of this.

Cheers,
Simon Brunning
TriSystems Ltd.
sbrunning@trisystems.co.uk

> -----Original Message-----
> From:	Daniel D. Laskey [SMTP:dlaskey@laskeycpa.com]
> Sent:	Saturday, August 26, 2000 6:18 PM
> To:	'tutor@python.org'
> Subject:	[Tutor] Example prog
> 
> I recently purchased "Programming Python" and I'm working through the
> examples.
> On page 83 Mark has a simple program called pack1.py.  What am I doing
> wrong?
> 
> Page 83, Programming Python
> 
> import sys
> marker = '::::::'
> 
> for name in sys.argv[1:]:
> 	input = open(name, 'r')
> 	print marker + name
> 	print input.read(),
> 
> C:\python>python pack1.py *.txt > stuff.txt
> 
> Traceback (innermost last):
>   File "pack1.py", line 5, in ?
>     input = open(name, 'r')
> IOError: [Errno 2] No such file or directory: '*.txt'
> 
> Daniel D. Laskey, CPA
> dlaskey@laskeycpa.com
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
> 
> 
> 
> 
-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.