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.

211 questions
6
votes
1 answer

error: command 'clang' failed with exit status 1 : On installing pandas on MacOS Big Sur M1

I install pandas using pip install pandas or pip3 install pandas. I get following infinite like error : (Note : I run these installations in virtualenv, created using python3 -m venv myenv) /* DISABLES CODE */ ( ) …
Ruchit Patel
  • 463
  • 2
  • 12
6
votes
2 answers

Zen of Python 'Explicit is better than implicit'

I'm not sure if this is an opinionated question or if it is me misunderstanding what 'implicit' and 'explicit' really means in the context of Python. a = [] # my understanding is that this is implicit if not a: print("list is empty") # my…
6
votes
1 answer

Why does unpacking give a list instead of a tuple in Python?

This is really strange to me, because by default I thought unpacking gives tuples. In my case I want to use the prefix keys for caching, so a tuple is preferred. # The r.h.s is a tuple, equivalent to (True, True, 100) *prefix, seed =…
episodeyang
  • 466
  • 6
  • 14
6
votes
1 answer

Partial stub in PyCharm

I would like to introduce partial type annotation to my project. For example for overloading. I found that pep561 introduce partial stub file support. I develop my project with PyCharm and I add corresponding *.pyi file. And got expected…
Grzegorz Bokota
  • 1,341
  • 7
  • 14
6
votes
1 answer

Type annotation style (to space or not to space)

Having the following function: def foo(x=1): print(x) It is clearly stated in PEP 8 that no spaces should be used around the = sign when used to indicate a keyword argument or a default parameter value. If we want to type-annotate the x…
Peque
  • 10,375
  • 7
  • 48
  • 83
6
votes
1 answer

Which implementation of OrderedDict should be used in python2.6?

As some of you may know in python2.7/3.2 we'll get OrderedDict with PEP372 however one of the reason the PEP existed was because everyone did their own implementation and they were all sightly incompatible. So which one of the 8 current…
Jorge Vargas
  • 6,002
  • 7
  • 30
  • 29
6
votes
7 answers

how can I make a suggestion for a new feature in python

Suppose I think I have a great idea for some feature that should be in python's standard library. Not something of the magnitude of a new keyword etc, just a suggestion for another decorator that would help a lot, IMO. How can I suggest such a…
olamundo
  • 21,047
  • 32
  • 99
  • 142
5
votes
3 answers

What is this Python type hinting syntax, two types enclosed in parenthesis?

I have a method with signature as follows: def get_users_for_survey(survey_id: (int, str),show_deleted_users: bool = False) -> list: pass I have avoided the method body because I am only interested in the type hinting part for survey_id? Looks…
Subhendu Mahanta
  • 753
  • 12
  • 30
5
votes
2 answers

Python - define constant inside function

Given that there are no real constants in Python, the convention is to name them in CAPS for conveying the intentions. In following sample code, FIRST and SECOND are constants: def fibonacci_generator(count): FIRST, SECOND = 0, 1 a, b =…
Sagar Gupta
  • 1,040
  • 9
  • 24
5
votes
1 answer

PEP 3106 suggests slower way? Why?

Recently, I had to convert the values of a dictionary to a list in Python 3.6 and an use case where this is supposed to happen a lot. Trying to be a good guy I wanted to use a solution which is close to the PEP. Now, PEP 3106…
d4tm4x
  • 190
  • 1
  • 10
5
votes
1 answer

What is the standard docstring for a django model metaclass?

Models in django can come with a meta class like so: class Address(models.Model): """Address model.""" class Meta: """Meta McMetaface.""" verbose_name = "Address" verbose_name_plural = "Addresses" address_line…
Pureferret
  • 6,477
  • 14
  • 72
  • 149
5
votes
2 answers

Regex to match PEP440 compliant version strings

PEP 440 lays out what is the accepted format for version strings of Python packages. These can be simple, like: 0.0.1 Or complicated, like: 2016!1.0-alpha1.dev2 What is a suitable regex which could be used for finding and validating such strings?
Leo
  • 779
  • 8
  • 19
5
votes
1 answer

Has there been any Python proposal for conditional "except" blocks?

In systems programming it is common to invoke some library function which may fail, and if it does fail, to check errno for the exact cause. This is true even in Python, and I think it's more cumbersome than it needs to be. Let's take for example…
John Zwinck
  • 207,363
  • 31
  • 261
  • 371
5
votes
5 answers

Python: imports at the beginning of the main program & PEP 8

The PEP 8 recommends that modules be imported at the beginning of programs. Now, I feel that importing some of them at the beginning of the main program (i.e., after if __name__ == '__main__') makes sense. For instance, if the main program reads…
Eric O Lebigot
  • 81,422
  • 40
  • 198
  • 249
4
votes
0 answers

Why there is no max heap data type in Python Standard Library?

I have read the topic What do I use for a max-heap implementation in Python? that has been viewed more than 74k times as of today (meaning that many people came across the same issue) and I've been wondering what is the reason for not implementing…
Tomasz Bartkowiak
  • 5,269
  • 1
  • 38
  • 44
1 2
3
14 15