which

Jean-Michel Pichavant jeanmichel at sequans.com
Fri Feb 5 15:41:34 CET 2010


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)
>
>
I would vote for the first one. But I could use the second as well, I 
would'nt fight for it.

What is worrying me the most in your code sample is that self.cmd can 
hold diferrent types (str, and something else). That is usually a bad 
thing to do (putting None aside).
However, my remark could be totally irrelevant of course, that depends 
on the context.

JM




More information about the Python-list mailing list