pep Questions

8

Solved

I get this pep8 warning whenever I use lambda expressions. Are lambda expressions not recommended? If not why?
Skinny asked 29/7, 2014 at 7:26

7

Solved

Long story short PEP-557 introduced data classes into Python standard library, that basically can fill the same role as collections.namedtuple and typing.NamedTuple. And now I'm wondering how to s...
Blackguard asked 3/8, 2018 at 11:32

4

Solved

I was just wondering what is the difference between two ways of writing Python Docstrings (__doc__): three single quotes: ''' Comment goes here ''' three double quotes: """ Comment goes here ...
Undeviating asked 26/10, 2012 at 5:22

6

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) /* DIS...
Limitary asked 30/1, 2021 at 12:34

4

Solved

What is the preferred way to write Python doc string? """ or " In the book Dive Into Python, the author provides the following example: def buildConnectionString(params): ...
Microtone asked 14/7, 2013 at 21:22

2

I would like to add type hints to a method that takes a numpy array as an input, and returns a string. This numpy array contains floats so I tried: import numpy as np def foo(array: np.ndarray[np....
Etymology asked 16/10, 2018 at 15:51

3

Solved

I'm trying to understand 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 ...
Flotilla asked 25/9, 2020 at 19:13

4

Solved

I can't find any PEP reference to this detail. There has to be a blank line after function definition? Should I do this: def hello_function(): return 'hello' or shoud I do this: def hello_fun...
Stirpiculture asked 20/9, 2013 at 10:6

1

What is the canon (based on some PEP) way to style a function definition with long type annotations? Some alternatives I can conceive: Option 1: def my_long_function_name_super_important( first_...
Varioloid asked 26/2, 2021 at 11:52

3

Solved

I found the documentation for pep8 but wasn't able to understand how to write these. I couldn't even find any examples with options other than setting max-line-length and ignore. I am trying to wr...
Feeder asked 18/5, 2015 at 13:23

1

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 ...
Essayist asked 14/3, 2019 at 11:0

1

Solved

I was looking into how Python represents string after PEP 393 and I am not understanding the difference between PyASCIIObject and PyCompactUnicodeObject. My understanding is that strings are repres...
Ardeliaardelis asked 16/6, 2020 at 5:37

1

Solved

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, equivalen...
Sapir asked 25/4, 2020 at 16:22

2

One of the examples given in PEP572 is # Reuse a value that's expensive to compute [y := f(x), y**2, y**3] currently in python, you'd have to do one of the following: # option 1 y = f(x) [y, y*...
Decompensation asked 1/8, 2019 at 12:30

2

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_gene...
Kain asked 5/9, 2019 at 8:29

1

Solved

I noticed that the sqlite3-library still uses the __conform__-method to adapt objects for storage in a database. Then you need to give your class a method __conform__(self, protocol) which must ...
Ybarra asked 5/4, 2018 at 13:7

1

Solved

I was looking at the PEP 484 section on Forward References and noticed the statement: ...that definition may be expressed as a string literal, to be resolved later. And that got me wondering, whe...
Caducity asked 24/3, 2019 at 2:28

2

Solved

Is there a specific reason the numpy function arange was named so? People habitually make the typo arrange, assuming it is spelled as the English word, so the choice seems like something of an ov...
Disordered asked 11/3, 2019 at 13:22

8

Solved

Should I test if something is valid or just try to do it and catch the exception? Is there any solid documentation saying that one way is preferred? Is one way more pythonic? For example, shoul...
Chuckchuckfull asked 29/9, 2011 at 23:55

2

Solved

I was scrolling through the PEP index page and noticed that a PEP number was reserved by ‘Warsaw’: PEP PEP Title PEP Author(s) I 801 Reserved Warsaw I looked it up out of curiosity an...
Bellay asked 4/4, 2018 at 11:34

6

Solved

Recently I started using Python3 and it's lack of xrange hurts. Simple example: Python2: from time import time as t def count(): st = t() [x for x in xrange(10000000) if x%4 == 0] et = t() pri...
Linsang asked 21/2, 2013 at 23:36

1

Solved

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 clo...
Bole asked 20/3, 2018 at 12:27

2

Solved

I am trying to write a small Python 2.x API to support fetching a job by jobNumber, where jobNumber is provided as an integer. Sometimes the users provide ajobNumber as an integer literal beginning...
Delfeena asked 16/7, 2012 at 22:22

1

Solved

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 paramet...
Homoousian asked 11/5, 2017 at 11:31

1

Solved

Definition of "Dunder" (Double underscore): http://www.urbandictionary.com/define.php?term=Dunder I have a question according the placement of module level "dunders" (like __all__, __version__, ...
Rickets asked 19/8, 2016 at 17:1

© 2022 - 2024 — McMap. All rights reserved.