For Python code, PEP 257 provides a convention for using docstrings to document structural entities: packages, modules, functions, classes, and methods. This covers pretty much everything. Stack Overflow questions about how to comment Python code invariably elicit answers saying to use docstrings. Where does this leave comments? Is the Pythonic approach to use docstrings exclusively and never use comments? Or do
Tag: conventions
Is there a standardized method to swap two variables in Python?
In Python, I’ve seen two variable values swapped using this syntax: Is this considered the standard way to swap two variable values or is there some other means by which two variables are by convention most usually swapped? Answer Python evaluates expressions from left to right. Notice that while evaluating an assignment, the right-hand side is evaluated before the left-hand