Skip to content
Advertisement

Tag: pep8

PEP 8 – Aligning parameters by adding whitespace [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 1 year ago. Improve this question I have a tendency to align my code by adding whitespace in the following (unconventional) way. PEP-8 doesn’t seem to discuss

What is the naming convention for Python class references

What is the naming convention for a variable referencing a class in Python? Here is another example that resembles my situation: I would prefer ReferenceToClass, that everybody new to the code knows it’s a class and not an instance. But as poplitea wrote, literature reference would be great. Answer On module level the second: ReferenceToClass = MyClass As a function

How to break a line of chained methods in Python?

I have a line of the following code (don’t blame for naming conventions, they are not mine): I don’t like how it looks like (not too readable) but I don’t have any better idea to limit lines to 79 characters in this situation. Is there a better way of breaking it (preferably without backslashes)? Answer You could use additional parentheses:

“assert” statement with or without parentheses

Here are four simple invocations of assert: Note that the last one does not raise an error. What is the difference between calling assert with or without parenthesis that causes this behavior? My practice is to use parenthesis, but the above suggests that I should not. Answer The last assert would have given you a warning (SyntaxWarning: assertion is always

Advertisement