On 08/11/12 09:39, Sylvain Thénault wrote:
On 08 novembre 09:26, Omega Weapon wrote:
On 08/11/12 08:31, Sylvain Thénault wrote:
On 07 novembre 20:00, Omega Weapon wrote:
On 07/11/12 07:34, afayolle wrote:
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.
Fine, but I can't think of a case where message type will be an empty string.
Not a big deal though.
That isnt the point - it copes with both a single character msgtype
and one with the ID appended at the same time, no if needed.
It is somewhat the point: msg[0][0] is more readable than msg[0][1:], to me at
least.
Difference being the second option is resilient to empty string, so one may
ask if this empty string case may occur or not.
I have committed:
https://bitbucket.org/OmegaPhil/pylint/changeset/59bfe07bcda8297816a1d6ef5fbada2d4e2492f3
Yes, I agree with you. An empty message should cause an error because
its a bug in this context as its relied upon just after.
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects