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
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
  • 91,433
  • 48
  • 218
  • 260
4
votes
3 answers

Does anything supercede PEP 8?

Trying to go from a script kiddie to a semi-respectable software engineer and need to learn how to write clean, digestible code. The book I'm reading pointed me towards PEP 8 - I know this is the foundational styling guide for Python. What I can't…
4
votes
3 answers

How to use the Python packaging library with a custom regex?

I'm trying to build and tag artifacts, the environment name gets appended at the end of the release, e.g.: 1.0.0-stg or 1.0.0-sndbx, none of them are PEP-440 compliance, raising the following error message: raise InvalidVersion(f"Invalid version:…
javierlga
  • 1,409
  • 9
  • 14
4
votes
0 answers

Support for tensor type hints (variadic generics) in Numpy (PEP 646)

Context: As of Python 3.11, variadic generics are supported as detailed in PEP 646. The idea behind variadic generics is to facilitate the annotation of tensors (or multiple dimensional arrays), like this example (from PEP 646): def to_gray(videos:…
Hylke
  • 75
  • 6
4
votes
1 answer

Typing a Decorator that Accepts Arguments via ParamSpec (PEP-612, Python 3.10)

I was reading PEP-612 and it makes typing a decorator fairly tractable. Also, the example provided in the PEP makes it look pretty easy. This example is copied directly from the PEP: from typing import ParamSpec, TypeVar from collections.abc import…
Redowan Delowar
  • 1,580
  • 1
  • 14
  • 36
4
votes
2 answers

VSCode settings for search paths with PEP582 & ipykernel

I used python package managers (PyFlow/PDM) which supports PEP582: packages are installed in the local directory {workspace_path}/__pypackages__/. I added some configs in settings.json to let VSCode know how to find the packages: { ..., …
Xaree Lee
  • 3,188
  • 3
  • 34
  • 55
4
votes
1 answer

PEP508: why either version requirement or URL but not both?

When configuring install_requires=[...] in a setup.py file, we can specify either version numbers: package >= 1.2.3 or a source: package @ git+https://git.example.com/some/path/to/package@master#egg=package But I did not manager to specify both, I…
VPfB
  • 14,927
  • 6
  • 41
  • 75
4
votes
1 answer

Keycloak fine grained permissions with Spring Boot / Spring Security

I would like to use permissions or scopes or similar to allow fine grained access to REST resource. Ideally I would like to do something like: @PreAuthorize("hasPermission('Brands', 'brands:write')") ResponseEntity
David
  • 251
  • 1
  • 2
  • 5
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
  • 12,154
  • 4
  • 57
  • 62
4
votes
0 answers

What is the system-provided certificate database (Python PEP 476)?

Extract from PEP 476: This PEP proposes using the system-provided certificate database. Previous discussions have suggested bundling Mozilla's certificate database and using that by…
Astrophe
  • 568
  • 1
  • 7
  • 25
4
votes
2 answers

function annotations in python

I just discovered function annotations for python 3 (https://www.python.org/dev/peps/pep-3107/) which seems great for documenting parameters or return types. It also makes better intellisense available in my pycharm IDE. I have a question regarding…
Luca
  • 10,458
  • 24
  • 107
  • 234
4
votes
3 answers

Python - most convenient way to define constant variables used just once

Let's say I have a file "icon.ico" and an url "url.com". The'll be used just once within the class - "icon.ico" will be set to some window and we'll do the request to url in one method. I have three ways to define these variables. 1-st way - define…
GriMel
  • 2,272
  • 5
  • 22
  • 40
4
votes
1 answer

No lxml Wheel for Linux?

The lxml project has decided to not provide a Wheel for lxml on Linux: https://bugs.launchpad.net/lxml/+bug/1176147 I am neither an expert on PEP 427 or lxml's dependencies, so I'm hoping someone can explain why or why not the lxml team's concerns…
Charles Offenbacher
  • 3,094
  • 3
  • 31
  • 38
4
votes
2 answers

Why do future_statements in Python need to be placed before everything?

PEP 236 states clearly that all future_statements must appear near the top of a module, with only comments, docstrings and the like allowed before them. I understand that this isn't debatable as a programming practice - it's the rules and they're…
mechalynx
  • 1,306
  • 1
  • 9
  • 24
4
votes
1 answer

where to position argparse in code

I'm currently implementing command line arguments in my python script and want to be as pythonic as possible. Thus I'm using argparse and am currently reading trough the documentations tutorial. What's not clear to me, as I have def main(): def…
Daedalus Mythos
  • 565
  • 2
  • 8
  • 24