Re: [Tutor] Lists of files

2005-05-17 Thread Karl Pflästerer
On 16 Mai 2005, [EMAIL PROTECTED] wrote: > Thanks to all who helped me with my questions regarding testing for > commandline arguments and list assignment. I have finished my first > Python program (included below). It is slightly more secure than the > Perl program I rewrote, but also about a t

Re: [Tutor] Lists of files

2005-05-16 Thread William O'Higgins
Thanks to all who helped me with my questions regarding testing for commandline arguments and list assignment. I have finished my first Python program (included below). It is slightly more secure than the Perl program I rewrote, but also about a tenth of a second slower (0.6 seconds for Perl on a

Re: [Tutor] Lists of files

2005-05-14 Thread Karl Pflästerer
On 14 Mai 2005, [EMAIL PROTECTED] wrote: > Here's the problem - I want a list (array) of the files in a directory, > and then I want to iterate over the list testing for image-ness (with > imghdr.what()) and put all the image filenames in a global list. > > What I've tried is this: > > files = glo

Re: [Tutor] Lists of files

2005-05-14 Thread Bernard Lebel
Hi William, First, check out the os and os.path modules. It has exactly what you need to handle files and directories. http://www.python.org/doc/2.4.1/lib/module-os.html More specifically: http://www.python.org/doc/2.4.1/lib/os-file-dir.html http://www.python.org/doc/2.4.1/lib/module-os.path.html

[Tutor] Lists of files

2005-05-14 Thread William O'Higgins
Here's the problem - I want a list (array) of the files in a directory, and then I want to iterate over the list testing for image-ness (with imghdr.what()) and put all the image filenames in a global list. What I've tried is this: files = glob.glob('*.*') for file in files: global pics