"bill" <[EMAIL PROTECTED]> writes: > Consider the following: > > import os, commands > os.environ['QWE']="string with foo" > a = '$QWE ${QWE/foo/baz}' > b = commands.getoutput('echo ' + a) > > > This does what I want, which is to expand > a according to the standard bash expansion rules > (so b now references "string with foo string with baz"), > but it doesn't feel right. > > Is there a more pythonic way to interpret strings according > to shell rules for word expansion? Relying on commands > feels like a kludge, and shlex is way too much work for this > (not to mention that it doesn't really address the issue).
Well, if you really want shell rules, I think you're out of luck. Espcially since those rules tend to vary depending on what shell you're running. I don't think that even shlex will do what you want. If you just want the simple cases you used in your example, you might check out the Template module in 2.4. <mike -- Mike Meyer <[EMAIL PROTECTED]> http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list