Marc Buehler wrote:
> i would like to extract the number of JPG files
> from the current directory and use that number
> as a parameter in my python script.
> i tried:
>  a = os.system('ls *JPG | wc -l')
> when i do:
>  print a
> i get '0'.
> 
> what am i missing?

os.system() returns the exit code of the program, not the output. You can run 
an external program and capture the output, but generally you should look for a 
solution within Python before resorting to external programs. In this case, try

import glob
a = len(glob.glob('*.JPG'))

Kent

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to