Access all classes in a directory, put into an array, and print t hem out

Kemp Randy-W18971 Randy.L.Kemp at motorola.com
Tue Jul 3 09:49:22 EDT 2001


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