[Tutor] subprocess Popen PIPE error

Abhijeet Rastogi abhijeet.1989 at gmail.com
Tue Oct 26 18:39:27 CEST 2010

Ya. Do it using python. Why do you want to use bash when you already have

See, do something like this:-

import os
alldirs = os.listdir("/path/to/dir")

DIRS = [] #Only the dirs you are interested in

for i in alldirs:
      if i.find("deploy") is -1: L.append(i)
      if i.find("TEMPLATE") is -1: L.append(i)

#Now L contains all the required dirs.

Hope it helps.

On Tue, Oct 26, 2010 at 9:19 PM, Sean Carolan <scarolan at gmail.com> wrote:

> > Here is the bash one-liner that generates my list,
> > with one name per line:
> >
> > ls -d */ | grep -v -E 'deploy|TEMPLATE' | sed 's/\///'
> >
> > How would you get the output of this into a python list that could
> > then be used in the script?  Please forgive my ignorance; I've read
> > through the documentation but am still not clear on this aspect.
> Would this be easier to accomplish using os.listdir()?.  Basically I
> want to make a list of directories, excluding files and the
> directories or files containing "deploy" and "TEMPLATE".

Abhijeet Rastogi (shadyabhi)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101026/1daf2e1e/attachment.html>

More information about the Tutor mailing list