pep8

Why are PIL and its Image module capitalized?

Why are PIL and its Image module capitalized? Question: PEP8 standard is for modules to be lower-case PIL being a top-level module in all caps isn’t so bad, but to name a module Image and then have a class in that module called Image seems unnecessarily confusing. Why was it done this way? Asked By: …

Total answers: 1

Phython: missing-function-docstring (pylance)

Phython: missing-function-docstring (pylance) Question: Im getting the message from pylace at my function. What to do? def retangulo(larg, comp): area = larg * comp print(f’A área de um terreno {larg} x {comp} é {area}.’) docstringpylint(missing-function-docstring) I am expecting to understand how to write python the "right way". Asked By: Renan Soares || Source Answers: … …

Total answers: 1

Python question about overridden/redifined imported function as Class method

Python question about overridden/redifined imported function as Class method Question: In https://github.com/biopython/biopython/blob/518c4be6ae16f1e00bfd55781171da91282b340a/Bio/SeqUtils/ProtParam.py I have this importing statement: from Bio.SeqUtils import molecular_weight and then in a Class: class ProteinAnalysis: ….. ….. def molecular_weight(self): """Calculate MW from Protein sequence.""" return molecular_weight( self.sequence, seq_type="protein", monoisotopic=self.monoisotopic ) …… …… What is this type of coding called? Is it normal …

Total answers: 3

How to break a long line with multiple bracket pairs?

How to break a long line with multiple bracket pairs? Question: How to break a long line with multiple bracket pairs to follow PEP 8’s 79-character limit? config["network"]["connection"]["client_properties"]["service"] = config["network"]["connection"]["client_properties"]["service"].format(service=service) Asked By: Maggyero || Source Answers: Using black, the opinionated, reproducible code formatter: config[“network”][“connection”][“client_properties”][ “service” ] = config[“network”][“connection”][“client_properties”][ “service” ].format( service=service ) Answered By: Reblochon …

Total answers: 5

Change indentation level in Google Colab

Change indentation level in Google Colab Question: I am using Google Colab to write Python code in their notebooks. Whenever I hit enter after a loop or conditional, the new line is automatically indented, which is good, but it uses only 2 whitespaces by default. This is contrary to the PEP-8 standard which recommends 4 …

Total answers: 1

How to choose proper variable names for long names in python

How to choose proper variable names for long names in python Question: I need help choosing proper names for variables with long actual names. I have read pep8 docs, but I couln’t find addressed such issue. Would you rename very_long_variable_name to something like vry_lng_var_nm or would you leave it as it is. I notice that …

Total answers: 1

comparison to False should be 'if cond is False:' or 'if not cond:

comparison to False should be 'if cond is False:' or 'if not cond: Question: while line_number < dictionary_elements_number and validation_bool == False: getting this error when i run it throught pep8 E712 comparison to False should be ‘if cond is False:’ or ‘if not cond:’ isn’t that a bit weird? Asked By: Clara || Source …

Total answers: 2

How to tell flake8 to ignore comments

How to tell flake8 to ignore comments Question: I’m using flake8 in emacs in order to clean up my python code. I find it annoying to have my comments flagged as errors (E501 line too long (x > 79 characters)). I’m wondering if anyone knows a way to kindly ask flake8 to ignore comments, both …

Total answers: 3

What does '# noqa' mean in Python comments?

What does '# noqa' mean in Python comments? Question: While searching through a Python project, I found a few lines commented with # noqa. import sys sys.path.append(r’C:dev’) import some_module # noqa What does noqa mean in Python? Is it specific to Python only? Asked By: Ishpreet || Source Answers: Adding # noqa to a line …

Total answers: 4

Does PEP8 suggest returning a variable or a function call from a method?

Does PEP8 suggest returning a variable or a function call from a method? Question: What is the recommended way for returning values from a method and why, according to PEP8? I tried finding documentation on this in PEP8, but couldn’t find anything. Method 1 def method(): a = meth2() return a Method 2 def method(): …

Total answers: 4