Neal Becker a écrit : > I have a list of strings (sys.argv actually). I want to print them as a > space-delimited string (actually, the same way they went into the command > line, so I can cut and paste) > > So if I run my program like: > ./my_prog a b c d > > I want it to print: > > './my_prog' 'a' 'b' 'c' 'd'
This should do what you want: print " ".join("'%s'" % arg for arg in sys.argv) NB : if your version of Python predates generator expressions, use a list comp instead: print " ".join(["'%s'" % arg for arg in sys.argv]) -- http://mail.python.org/mailman/listinfo/python-list