For some reason, pylint 1.6.4 (astroid 1.4.9) doesn't like it:
try: some_package.their_function() except Exception as ex: if ex.message.startswith(...): ...
He complains:
error (E1101, no-member, feed_sentiment) Class 'message' has no 'startswith' member
I find this amazing because:
>>> type(Exception("foo").message) <type 'str'> >>> Exception("foo").message.startswith <built-in method startswith of str object at 0x10520d360>
I think this is a bug in pylint .
However, am I doing something wrong? What is the "pythonic" way here?
PS. Yes, I know that the correct way is to define my own subclass of exceptions, but I cannot control some_package .
SFC. Yes, I know that I can annotate the code with pylint: disable=no-member .
source share