On 07/11/12 07:34, afayolle wrote:
On 06/11/2012 17:44, Julien Cristau wrote:
First, let me thank you for the patch.

On Sat, Oct 27, 2012 at 12:54:40 +0100, Omega Weapon wrote:

I have forked the Bitbucket pylint repo and committed here: 
https://bitbucket.org/OmegaPhil/pylint/changeset/87bc90372e57064bb97866b47e34de12747889c1

Couldn't
msgType = msg[0][:1] if len(msg[0])>  1 else msg[0]
be rewritten as
msgType = msg[0][0]
?


I have not looked in depth as the code, but msg[0][0] will throw an
IndexError if len(msg[0]) == 0, whereas the above code will set msgType
to an empty list.

Using msgType = msg[0][:1] will work regardless of len(msg[0]) (since
slices never generate IndexError).


Thanks for the responses - back on this now. I completely missed the latter fact - thanks afayolle... not even a need for an if! So the whole problem is solved with the '[:1]'.

https://bitbucket.org/OmegaPhil/pylint/changeset/a9c692e0329069ab75f2e915ac017cd2e3a6502b has now been committed.
_______________________________________________
Python-Projects mailing list
Python-Projects@lists.logilab.org
http://lists.logilab.org/mailman/listinfo/python-projects

Reply via email to