[Python-3000] os.popen versus subprocess.Popen (original) (raw)
Facundo Batista facundobatista at gmail.com
Tue Apr 22 21:52:42 CEST 2008
- Previous message: [Python-3000] os.popen versus subprocess.Popen
- Next message: [Python-3000] os.popen versus subprocess.Popen
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2008/4/22, Andrew McNabb <amcnabb at mcnabbs.org>:
Here's a really simple example:
("bash", "-c", 'FILE="/tmp/a b c"; cat "$FILE"') That's pretty simple as a list of arguments. But if you do it as a single string, you get: 'bash -c 'FILE="/tmp/a b c"; cat "$FILE"'' It can get much worse than this, especially if you need to use backslashes.
I think that force me to write a tuple or a list just in case I'd need to write a string that uses simple and double quotes, or backslashes, because it's "ugly", don't worth it.
What about growing the possibility of write a tuple/list or a string, and if I have a string, just use it? You could say that writing a plain string I incur in the risk of not enclosing the parameters correctly at bash level, but note that you're still doing that quote enclosing even in the tuple/list, and that Python normally treats the programmer as an adult.
Regards,
-- . Facundo
Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/
- Previous message: [Python-3000] os.popen versus subprocess.Popen
- Next message: [Python-3000] os.popen versus subprocess.Popen
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]