Python Forum
long lines, longer than 72 or 79
Thread Rating:
  • 2 Vote(s) - 1.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
long lines, longer than 72 or 79
#1
i'm cleaning up a lot of code, including trying to make it fit in 72 columns, or at least in 79 columns.  most things are going ok.  a few things are being difficult.  is there any general scheme for making long code lines fit well?

i have these right now:

        raise TypeError('Not a number passed to unmod() arg2: %s (modulus)' % repr(m))
        raise TypeError('Not a number passed to unmod() arg1: %s (value)' % repr(n))
        raise ValueError('Negative value passed to unmod() arg2: %s (modulus)' % repr(m))
what is a good way to split the long lines and keep things readable?  is there a better (and hopefully shorter) way to code them?  they are separate lines.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
One way

raise TypeError(
        'Not a number passed to unmod() arg2: %s (modulus)' % repr(m))
raise TypeError(
        'Not a number passed to unmod() arg1: %s (value)'
        % repr(n)
raise ValueError('Negative value passed to unmod() arg2: %s (modulus)'
        % repr(m))
Some statements like with may need \. According to pep 8

Some examples here and in the next three chapters there are more
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Beginner: Code not work when longer list raiviscoding 2 810 May-19-2023, 11:19 AM
Last Post: deanhystad
  a longer docstring Skaperen 8 1,643 Aug-25-2022, 11:21 PM
Last Post: Skaperen
  IDLE editing window no longer works chris1 2 2,189 Feb-06-2021, 07:59 AM
Last Post: chris1
  Code no longer working yk303 14 10,068 Dec-21-2020, 10:58 PM
Last Post: bowlofred
  ReferenceError: weakly-referenced object no longer exists MrBitPythoner 17 11,462 Dec-14-2020, 07:34 PM
Last Post: buran
  Iterate 2 large text files across lines and replace lines in second file medatib531 13 5,766 Aug-10-2020, 11:01 PM
Last Post: medatib531
  My code is taking longer time to give result rajeshwin 4 3,275 Feb-20-2019, 08:18 PM
Last Post: ichabod801
  Catching exceptions in embedded code no longer works on 3.7.2? FFMG 5 3,357 Feb-02-2019, 10:15 AM
Last Post: Larz60+
  Help with rhel 7 that no longer has ConsoleKit Rocketrrt 1 18,724 Sep-25-2016, 07:25 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020