popen - reading strings - constructing a list from the strings

Aytekin Vargun varguna at gmail.com
Wed May 20 11:17:50 EDT 2009


 <python-list at python.org>
Hello everybody,
I have a question about the way I use os.popen. I am open to other
alternative suggestions like using subprocess or communicate.

I have an executable (say read_cell_types.exe) that produces string outputs.
For example, after one execution I got the following outputs in one line:

Neurons Microglia Astrocytes

In another execution, there might be different numbers of strings.

What I would like to do is to get these strings after running
read_cell_types.exe from my python program dynamically  and construct radio
buttons from the list of strings. In order to do this I need to construct a
list of strings first as in

["Neurons" "Microglia" "Astrocytes"]

Then it is easy to construct the radio buttons.

When I use the following code

command = "read_cell_types " + fileName2
child = os.popen(command)
data = child.read()
allObjects=data

allObjects (or data) contains the letters of all string words. I think it is
probably like ["N" "e" "u" "r"  ...]

How can I construct ["Neurons" "Microglia" "Astrocytes"] instead?

I will really appreciate your help.
Thanks a lot.

PS: fileName2 is a parameter  that I am passing to read_cell_types.exe

Aytekin

-- 
My web page: http://www.cs.rpi.edu/~vargua
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090520/8c39e8d8/attachment.html>


More information about the Python-list mailing list