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

  • SEARCH
  • Home
  • 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 3988214
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:13:32+00:00 2026-05-20T06:13:32+00:00

When indenting long if conditions, you usually do something like this (actually, PyDev indents

  • 0

When indenting long if conditions, you usually do something like this (actually, PyDev indents like that):

if (collResv.repeatability is None or
    collResv.somethingElse):
    collResv.rejected = True
    collResv.rejectCompletely()

However, this puts the block started by the if statement on the same indentation level as the last part of the if condition which makes it very ugly/hard to read in my opinion as you don’t immediately see where the block starts.

Some other styles I thought about:

if (collResv.repeatability is None or
        collResv.somethingElse):
    collResv.rejected = True
    collResv.rejectCompletely()

This looks pretty inconsistent as the second line is indented much more than the first line but it’s readable.

if (collResv.repeatability is None or
  collResv.somethingElse):
    collResv.rejected = True
    collResv.rejectCompletely()

This is also more readable than the first example, but the indentation is not a multiple of 4 anymore and besides that it looks wrong as the second line has less indentation than the beginning of the condition in the first line.


So, my main question is: Is there a suggested indentation style for cases like that which do not require overly-long lines (i.e. a single-line condition)?
If not, what do you prefer for cases like that?

  • 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-20T06:13:32+00:00Added an answer on May 20, 2026 at 6:13 am

    This is an indirect answer–not answering the style question directly, but it’s the practical answer in general, so it’s worth mentioning.

    I find it extremely rare to need to write multi-line conditionals. There are two factors to this:

    • Don’t wrap code at 80 columns. PEP-8’s advice on this subject is ancient and harmful; we’re well past the days of 80×25 terminals and editors that can’t sensibly handle wrapping. 100 columns is fine, and 120 is usually acceptable, too.
    • If conditions become so long that they still need to wrap, it’s usually reasonable to move some of the logic out of the conditional and into a separate expression. This also tends to help readability.

    Grepping through my recent projects, around 12kloc, there’s only one conditional long enough that it needed to be wrapped; the issue simply very rarely arises. If you do need to do this, then as nosklo says, indent it separately–as you noticed, indenting it to the same level as the block beneath it is confusing and hard to read.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a perl script that is inserting records from a text file into
Base information: This is in context to the indexing process of OpenStreetMap data. To
I'm using a debug output using printf() in my functions, but the output goes
We develop for web. For some reason our design team hates [the look of]
so I'm inserting an <input type=file> object into a fairly small table....everything works fine,
I got problem inserting the string AM/PM to my mySQL table $timeFormat = mysql_real_escape_string($_POST['timeFormat']);
I have encountered a problem while inserting a large amounts of text into my
I am trying to set an identity field's value before inserting the new record
i need some help with inserting multiple rows from different arrays into my database.
I run an online literary journal which leads to an indexing problem--our content is

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.