Questions tagged [pep]

Python Enhancement Proposals are used to propose and document Python language features, development processes and best practices. Use [pep8] for questions about the style guide for Python code.

Python Enhancement Proposals are used to propose and document Python language features, development processes and best practices.

Some important PEPs are:

At a given moment, the status of a PEP can be any one of Draft, Deferred, Accepted, Rejected, Withdrawn, Accepted, Final or Replaced. Informational PEPs which are expected to continue being updated may alternatively have a status of Active.

This flowchart shows how the status of a PEP may evolve:

enter image description here

A public Mercurial repository contains a record of changes to PEPs.

Use for questions about the style guide for Python code.

243 questions
3
votes
3 answers

How can i break up this line to meet PEP8 requirements?

I am getting a 'Line too long error' in the PEP8 online checker for the 'category' attribute. My piece of code is as shown : class A: __tablename__ = 'items' category = relationship(Category, backref=backref('items', cascade='all,…
Jas Singh
  • 35
  • 4
3
votes
2 answers

PEP 333 Application Instances and Objects

I have recently been trying to learning about WSGI and moreover, how the web works in regards to Python. So I've been reading through Werkzeug and PEP333 to learn. However I've run up against a small question, that I think I understand but probably…
John Von Neumann
  • 617
  • 4
  • 15
3
votes
0 answers

PEP 484 vs. PyCharm 2017.1

I have few modules with many fields. PyCharm has not auto completion for some fields (e. g.: PyCharm does not support typping.NamedTyple). I added a description of these fields to stub file. And it worked in PyCharm 2016. But now PyCharm has better…
ADR
  • 1,255
  • 9
  • 20
3
votes
2 answers

python multiline comment indent

I have a Django project, and in some places we have multiline comments indented as follows: field = models.IntegerField(default=0, null=True) # 0-initial_email_sent # 1-second_email_sent …
3
votes
2 answers

Python syntactic sugar: function arg aliases

Is there any syntax for aliasing function args? If not, are there any PEP proposals? I'm not a programming languages theorist, so my opinion is probably uninformed, but I think implementing some sort of function arg aliasing could be useful. I'm…
crunk1
  • 2,560
  • 1
  • 26
  • 32
3
votes
2 answers

proper formatting of python multiline [ for in ] statement

How should i format a long for in statement in python ? for param_one, param_two, param_three, param_four, param_five in get_params(some_stuff_here, and_another stuff): I have found that i can brake a for in statement only with a backslash : for…
Alexander
  • 12,424
  • 5
  • 59
  • 76
3
votes
3 answers

Python PEP8 conventions

I'm a Python beginner, I read pep standards which must follow while programming in python http://legacy.python.org/dev/peps/pep-0008 Now I have a doubt. As they have mentioned that you should not put spaces around the equal sign while using keyword…
user3810188
  • 311
  • 1
  • 3
  • 14
3
votes
2 answers

Style of bitwise operators in Python

I can't find in PEPs information about style of bitwise operators (|, &), in this code in particular: class MySplashScreen(wx.SplashScreen): def __init__(self, parent=None): wx.SplashScreen.__init__(self, logo.getBitmap(),…
art.zhitnik
  • 604
  • 5
  • 19
2
votes
1 answer

Python @property method violating Protocol variable type annotation

I have an interface class Moveable(Protocol): position: Tuple[int, int] I implement the interface with a class that happens to use a getter to imitate the attribute position: Tuple[int, int] class Player: _x: int _y: int @property …
Michael Moreno
  • 947
  • 1
  • 7
  • 24
2
votes
1 answer

Is there an appropriate PEP error for failed threaded process?

This is a semantics question, but I'm trying to determine the correct Error to throw in the following situation. I have a process that sometimes is performed multiple times. If the process is performed an additional time before the first time is…
Asa LeHolland
  • 372
  • 4
  • 12
2
votes
1 answer

Best way to print detailed info to console

What is the best way to print detailed info to the console? I usually use f-strings for console output as for exampleprint(f"{data=}") is really handy. However i can't do join statements as the f-string expression part cannot include a backslash: #…
2
votes
1 answer

Pythonic usage or underscore (private) names in Python

I would like to know which would be more pythonic way to write python code using _ in modules, classes and methods. Example 1: import threading as _threading class Thread(_threading.Thread): pass vs from threading import Thread class…
Topi
  • 25
  • 4
2
votes
1 answer

strophe.js PEP handler not attaching properly

I have been using a PEP plugin (found here: https://github.com/flosse/strophejs-plugins/blob/master/pep/strophe.pep.js) to connect to a users node however I am having some trouble. When my connected block is called I do the…
Norman Joyner
  • 955
  • 6
  • 12
2
votes
1 answer

Linting variable annotation typo from PEP 526

I just had to debug a problem in production that boils down to the following behavior. What I should have typed: >>> import pandas as pd >>> from io import StringIO >>> a: pd.DataFrame = pd.read_csv(StringIO('a,b,c\n1,2,3')) >>> isinstance(a,…
Rafael Barbosa
  • 1,120
  • 12
  • 17
2
votes
0 answers

Preferred location for Python stub files

Is there a commonly agreed upon location for stub files in a Python project? It seems that the consensus would be to just place them in the same directory as the modules they are annotating - but this seems too messy and unorganised for Python. I…
jshwi
  • 84
  • 1
  • 1
  • 9