Access all classes in a directory, put into an array, and print them out
Emile van Sebille
emile at fenx.com
Tue Jul 3 10:15:32 EDT 2001
import os
for file in os.listdir(dirpath): print i
--
Emile van Sebille
emile at fenx.com
---------
"Kemp Randy-W18971" <Randy.L.Kemp at motorola.com> wrote in message
news:mailman.994168205.8845.python-list at python.org...
> Can anyone share a short code example of how to access all the programs in
a
> Unix directory, put them into an array, and print them out in Python?
Here
> is the code I have to do it in Perl (please forgive the harsh language).
>
> #!/usr/bin/perl -w
> #use Net::FTP;
> opendir (TEMP, '/usr2/ecadtesting/javaprograms')
> or die "Can't open current directory.";
> @files=join(',',grep(!/^\.\.?$/, readdir TEMP));
> closedir TEMP;
> print "\n";
> print @files;
> print "\n";
>
>
More information about the Python-list
mailing list