Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 988915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:42:23+00:00 2026-05-16T05:42:23+00:00

I am aware that the standard Python convention for line width is 79 characters.

  • 0

I am aware that the standard Python convention for line width is 79 characters. I know lines can be continued in a number of ways, such as automatic string concatenation, parentheses, and the backslash. What does not seem to be as clearly defined is how exactly the overflowing text should be formatted. Do I push it all the way back to col 1? To the col where the original line starts? To the start of the parentheses (if applicable)? For example, say I have something like this:


        self.someLongAttributeName = {'someLongKeyName':'someLongValueName',
                                      'anotherLongKeyName':'anotherLongValueName'}

Supposing that the format I used above would fit the 79 character limit, is the indentation of the second line correct?

Now suppose that the first line as shown above is > 79 characters. How should things look in that case?

NOTE: I know that a lot of people disagree with the 79-character convention. While I respect that there are a lot of pros and cons to each side of the issue, this debate is not relevant to my question. I am asking how to follow the convention, not whether or not I should, so please do not espouse the advantages of abandoning it in your reply. Thanks. =)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:42:23+00:00Added an answer on May 16, 2026 at 5:42 am

    Supposing that the format I used above would fit the 79 character limit, is the indentation of the second line correct?

    Yes, that’s how PEP 8 shows it in examples:

    class Rectangle(Blob):
    
        def __init__(self, width, height,
                     color='black', emphasis=None, highlight=0):
            if width == 0 and height == 0 and \
               color == 'red' and emphasis == 'strong' or \
               highlight > 100:
                raise ValueError("sorry, you lose")
            if width == 0 and height == 0 and (color == 'red' or
                                               emphasis is None):
                raise ValueError("I don't think so -- values are %s, %s" %
                                 (width, height))
            Blob.__init__(self, width, height,
                          color, emphasis, highlight)
    

    But when the opening parenthesis/brace is already close to the 79th column, I usually just exploit this:

    Two good reasons to break a particular rule:
    
    (1) When applying the rule would make the code less readable, even for
        someone who is used to reading code that follows the rules.
    [...]
    

    And do something like

    self.some_long_attribute_name = {
        'someLongKeyName': 'someLongValueName',
        'anotherLongKeyName': 'anotherLongValueName'
    }
    

    or

    long_object_name.do_something_with_long_name(
        long_expression_returning_is_first_arg,
        long_expression_returning_is_second_arg
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 510k
  • Answers 510k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You should not be running this from inside the myfirst… May 16, 2026 at 4:50 pm
  • Editorial Team
    Editorial Team added an answer In no particular order: Akka HTTP Spray Paypal squbs (Akka/Spray)… May 16, 2026 at 4:50 pm
  • Editorial Team
    Editorial Team added an answer See my answer to this question: can-we-connect-database-with-javascript. May 16, 2026 at 4:50 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

While I'm aware that you can't reference self directly in a decorator, I was
First, I am aware that dynamic languages is a term used mainly by a
I'm fully aware that the return value of std::type_info::name() is implementation-defined. From the C++
I am aware that this is somewhat a re-post, but I feel like re-posting
A user reported to us that some strange behaviour in our application can be
Python has a built in function sum , which is effectively equivalent to: def
What's the proper way to declare custom exception classes in modern Python? My primary
I've been asked to provide Numpy & Scipy as python egg files. Unfortunately Numpy
I'm looking for an equivalent to sscanf() in Python. I want to parse /proc/net/*
I have a Python module with nothing but regular global functions. I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.