Re: PEP8 compliance and exception messages ?



On Sun, Dec 5, 2010 at 7:40 PM, shearichard <shearichard@xxxxxxxxx> wrote:
Hi - PEP8 says lines should not exceed 79 characters in length
( http://www.python.org/dev/peps/pep-0008/ ).

So if you've got some code that looks like this :

raise fooMod.fooException("Some message which is quite long")

... and assuming a certain amount of indenting you're going to break
that guideline.

However there's a way around that ! You can do this ...

raise fooMod.fooException("\
       Some message \
       which is quite long")

... but the trouble is when that Exception is raised the message is
displayed as :

"Some message                     which is quite long"


I'm aware that a foolish consistency is the hobgoblin of something or
the other so maybe I should just let the PEP8 verifier complain but
otherwise does anyone have any ideas for how to get around this ?

Use implicit string literal concatenation:

raise fooMod.fooException(
"Some message "
"which is quite long")
#) # you could also put the closing paren here instead

Alternatively, you could disregard PEP 8 on this point on the grounds
that the 79/80 characters per line limit is outdated.

Cheers,
Chris
--
http://blog.rebertia.com
.



Relevant Pages

  • Re: wtf???
    ... purposes of determining the pot size for raising. ... maximum amount a player can raise is the amount in the pot after the call ... I'm basing this on the rules online, since that's where the OP's hand ... UTG can raise to $7 if hitting the "pot" button in a PL game ...
    (rec.gambling.poker)
  • Re: tricky situation
    ... aggressivley and after the river your cards never amount to anything. ... You'll find you leak away far fewer chips playing this way and might even ... means that you can only continue against a raise when you hold one of the ...
    (rec.gambling.poker)
  • Re: standard raise vs variable raise amount
    ... so that your opponents can't get a read on ... what your hand is based on the size of your raise. ... Keep the amount the same, ... blinds. ...
    (rec.gambling.poker)
  • Re: wtf???
    ... purposes of determining the pot size for raising. ... maximum amount a player can raise is the amount in the pot after the call ... I'm basing this on the rules online, since that's where the OP's hand ... UTG can raise to $7 if hitting the "pot" button in a PL game ...
    (rec.gambling.poker)