which

John Posner jjposner at optimum.net
Fri Feb 5 10:42:13 EST 2010


On 2/5/2010 9:21 AM, mk wrote:
>
> if isinstance(cmd, str):
>     self.cmd = cmd.replace(r'${ADDR}',ip)
> else:
>     self.cmd = cmd
>
> or
>
> self.cmd = cmd
> if isinstance(cmd, str):
>     self.cmd = cmd.replace(r'${ADDR}',ip)
>
>

(lunatic fringe?)

Last August [1], I offered this alternative:

   self.cmd = (cmd.replace(r'${ADDR}',ip)
               if isinstance(cmd, str) else
               cmd)

But it didn't get much love in this forum!


[1] 
http://groups.google.com/group/comp.lang.python/browse_thread/thread/6876917a4d579d59/1f700586f4c4614d?lnk=gst&q=Posner#1f700586f4c4614d



More information about the Python-list mailing list