Re: Snippet: The leanest Popen wrapper

2011-08-04 Thread Thomas Rachel
Am 04.08.2011 10:42 schrieb Chris Rebert: I was considering the more general case where one of the strings may have come from user input. You then need to also escape $looks_like_a_var, `some_command`, and way more other such stuff that your simple function doesn't cover. Even these things are

Re: Snippet: The leanest Popen wrapper

2011-08-04 Thread Chris Rebert
On Thu, Aug 4, 2011 at 1:10 AM, Thomas Rachel wrote: > Am 03.08.2011 19:27 schrieb Chris Rebert: > >>>                     shell= True, >> >> I would strongly encourage you to avoid shell=True. > > ACK, but not because it is hard, but because it is unnecessary and unelegant > at this point. > >> Y

Re: Snippet: The leanest Popen wrapper

2011-08-04 Thread Thomas Rachel
Am 03.08.2011 17:29 schrieb Phlip: Groupies: This is either a code snippet, if you like it, or a request for a critique, if you don't. Well, at first, I cannot see the real point about it... def command(*cmdz): process = Popen( flatten(cmdz), shell= True,

Re: Snippet: The leanest Popen wrapper

2011-08-04 Thread Thomas Rachel
Am 03.08.2011 19:27 schrieb Chris Rebert: shell= True, I would strongly encourage you to avoid shell=True. ACK, but not because it is hard, but because it is unnecessary and unelegant at this point. You really don't want to have to worry about doing proper shell esca

Re: Snippet: The leanest Popen wrapper

2011-08-03 Thread Terry Reedy
On 8/3/2011 11:29 AM, Phlip wrote: This is either a code snippet, if you like it, or a request for a critique, if you don't. A learning exercise but pretty useless otherwise. As others pointed out, immediately stripping off \n is a bug relative to *your* function description. Also, you yours

Re: Snippet: The leanest Popen wrapper

2011-08-03 Thread Phlip
> flatten() being defined as...? Python Cookbook recipe 4.6 def flatten(sequence): # CONSIDER: Reconcile with utils... for item in sequence: if isinstance(item, (list, tuple)): for subitem in flatten(list(item)): yield subitem else: y

Re: Snippet: The leanest Popen wrapper

2011-08-03 Thread Chris Rebert
On Wed, Aug 3, 2011 at 8:29 AM, Phlip wrote: > Groupies: > > This is either a code snippet, if you like it, or a request for a > critique, if you don't. > > I want to call a command and then treat the communication with that > command as an object. And I want to do it as application-specifically >

Re: Snippet: The leanest Popen wrapper

2011-08-03 Thread Thomas Jollans
On 03/08/11 17:29, Phlip wrote: > Groupies: > > This is either a code snippet, if you like it, or a request for a > critique, if you don't. > > I want to call a command and then treat the communication with that > command as an object. And I want to do it as application-specifically > as possible

Re: Snippet: The leanest Popen wrapper

2011-08-03 Thread Peter Otten
Phlip wrote: > Groupies: I smell a slight misperception of the audience you are addressing ;) > This is either a code snippet, if you like it, or a request for a > critique, if you don't. > > I want to call a command and then treat the communication with that > command as an object. And I want