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 8795333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:22:22+00:00 2026-06-13T23:22:22+00:00

Pep 8 has the following rules Blank Lines Separate top-level function and class definitions

  • 0

Pep 8 has the following rules

Blank Lines

Separate top-level function and class definitions with two blank
lines.

Method definitions inside a class are separated by a single blank
line.

Extra blank lines may be used (sparingly) to separate groups of
related functions. Blank lines may be omitted between a bunch of
related one-liners (e.g. a set of dummy implementations).

Use blank lines in functions, sparingly, to indicate logical sections.

Python accepts the control-L (i.e. ^L) form feed character as
whitespace; Many tools treat these characters as page separators, so
you may use them to separate pages of related sections of your file.
Note, some editors and web-based code viewers may not recognize
control-L as a form feed and will show another glyph in its place.

However, you can’t have a completely blank line inside a class defintion

Example from my head:

class bunny:
    def spam(self):
        pass

    def eggs(self):
        pass

#a second example
class bunny2:
    def __init__(self):
        self._eggs = None

    def eggs(self):
        doc = "Spam and Eggs"

        def fget(self, value):
            return self._eggs

        def fset(self, value):
            self._eggs = value

        def fdel(self):
            del self._eggs

        return locals()
    eggs = property(**eggs())

The line between spam and eggs needs to be a blank line, however, that will result in a parse error of unexpected indentation. Is there another character that should go in that space? My assumption is just leave the spaces/tabs on the “blank” line because it is more readable.

In the second example nested defs need to have their previous lines indention maintained for the parse to work correctly.
What is the correct PEP 8 way to handle this? Blank line, blank line with white space, no line?

  • 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-06-13T23:22:22+00:00Added an answer on June 13, 2026 at 11:22 pm

    If you’re working in the REPL, you can’t have entirely blank lines. But there is no reason for code entered in the REPL to strictly adhere to PEP 8, anyway. But inside a file, it is a good idea to follow PEP 8.

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

Sidebar

Related Questions

From PEP 8 : - Imports should usually be on separate lines, e.g.: Yes:
Function Annotations: PEP-3107 I ran across a snippet of code demonstrating Python3's function annotations.
According to PEP 8 : Imports should be grouped in the following order: standard
I don't understand the following from pep-0404 In Python 3, implicit relative imports within
Need help with understanding the following sentence from PEP 227 and the Python Language
Using the following query, WITH cteTest (Employee_ID) AS ( SELECT employee_ID FROM pep.dbo.labor_ticket )
I am trying to use an 'ordered class' as described in PEP 3115 (that
PEP 8 states: Imports are always put at the top of the file, just
I couldn't find answer after having read all the following: PEP 338 Executing modules
I'm using __package__ in setup.py to refer to the top-level name of the package

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.