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
0
votes
1 answer

PEP style guide for from module import with very nested module structure

Suppose I need the function foo and that foo just so happens to be defined under library.lgmodule.medmodule.smmodule.nichemodule.utils.something.else Is there a cleaner way to write: from…
SumNeuron
  • 4,850
  • 5
  • 39
  • 107
0
votes
1 answer

python: why is user script directory shared across python versions?

From PEP-370: user script directory A directory for binaries and scripts. [10] It's shared across Python versions and the destination directory for scripts. Unix (including Mac) ~/.local/bin Windows %APPDATA%/Python/Scripts Why does it…
Cyker
  • 9,946
  • 8
  • 65
  • 93
0
votes
0 answers

PyQt program structure to avoid garbage collection

I have a program which is becoming rather sizable. I have a main app class Pierre which encases all other major functions of the program and imports functions and classes from other scripts. My main problem right now is that I have a widget that is…
smallpants
  • 460
  • 7
  • 20
0
votes
3 answers

Where are detailed the rules, concepts and usages behind each pylint's warnings?

I am still discovering Pylint and I understand why many Pythonists deactivate some (or many) warnings to lower Pylint's voice, but for the moment, as a Python newbie I want to use pylint to improve my Pythonic comprehension and my code quality, in…
freezed
  • 1,269
  • 1
  • 17
  • 34
0
votes
2 answers

Return a complete expresion, or return its value stored in a variable

I am looking through some code and found the following lines: def get_char_count(tokens): return sum(len(t) for t in tokens) def get_long_words_ratio(tokens, nro_tokens): ratio = sum(1 for t in tokens if len(t) > 6) / nro_tokens return…
Bram Vanroy
  • 27,032
  • 24
  • 137
  • 239
0
votes
0 answers

Adding/calling/setting Class attributes outside of Class definiton

I have seen this coding pattern in codes I am (re)writing: class Outside(object): pass Outside.example = 10. My instinct was that I didn't like it! I'd prefer: class Inside(object): example = 10. Are there any advantages or situations…
innisfree
  • 2,044
  • 1
  • 14
  • 24
0
votes
1 answer

How do I import with absolute path in python packages with same name module?

eg. I have a package foo which has a module named foo.py /home/user/tmp/testPath/ …
Shuman
  • 3,914
  • 8
  • 42
  • 65
0
votes
2 answers

How can I find the publication history of Python PEPs?

While most PEPs have a created date, some do not, see PEP 249 for example. I'm curious about the history of the PEPs. Is there some resource that tracks the proposal, acceptance, and publication dates of such PEPs?
nsg
  • 10,510
  • 4
  • 21
  • 32
0
votes
1 answer

Can I change the 'app_azf_domain' in access token provided by Horizon?

I'm Testing FIWARE security GEris. But I have a problem when I use PDP (AuthzForce) with PEP Proxy (Wilma). Now, Wilma and AuthzForce are working well in separately. However, when I request resource to Wilma with an access token, Wilma retrieve the…
weepi
  • 35
  • 6
0
votes
2 answers

Must the encoding definition be in the 1st/2nd line in Python?

From PEP263: To define a source code encoding, a magic comment must be placed into the source files either as first or second line in the file, such as: # coding= or (using formats recognized by popular…
alvas
  • 115,346
  • 109
  • 446
  • 738
0
votes
1 answer

Database API specification for Java

Is there a Database API specification for Java that is similar to what exists for Python (PEP249). I'd like to make an application that can be used to connect to databases, universally, without worrying about the database engine type.
Sailesh Sriram
  • 144
  • 2
  • 17
0
votes
1 answer

Python static or not static

I recently started using PyCharm and it tells me whenever one of my methods can be static (whenever I don't use any member). I was wondering if it is a good practice to make methods static whenever I can or not. I know it's a bad habit in other…
lagagne
  • 25
  • 1
  • 1
  • 6
0
votes
1 answer

Protocol-driven circuit breaking operator

I came across the term "protocol-driven circuit breaking operator" in PEP 532, and couldn't find what exactly it means. Can you explain what this phrase means?
Simplicity
  • 47,404
  • 98
  • 256
  • 385
0
votes
4 answers

please suggest me the best practice in sting-value formating

i have a long string like below which i m trying to format aswel aligning it with PEP standards 'http://abc/api/run=1&'+ \ …
Arun G
  • 1,678
  • 15
  • 17
0
votes
1 answer

Less repeating yourself for re.sub with lists

I need to apply some regex substitutions on every element on a list. I wrote a function to repeat myself less. anyway there's still too much repeating. How could I optimize this? def cleanlist(mylist, regex, substitution): tmp_list = mylist …
royskatt
  • 1,190
  • 2
  • 15
  • 35