I would like to know recommendations about Implicit Line Joining versus Explicit Line Joining in Python.
In particular, do you favor one form over the other? What do you recommend as the general default? What criteria do you have for choosing one over the other, and if you do have a preference of one, when do you make exceptions for the other?
I have an answer in mind for this question that reflects my own biases, but before I post my own answer I would like to know what others think… and if you can have a better set of criteria than what I have in mind, then I'll certainly accept your answer over my own.
Some of the recommendations may be generalized to this choice in other programming languages, but my own bias is somewhat stronger in Python due to some language-specific features, so I'd like to know both the general and the Python-centric reasoning you may have on this topic.
For some background, the discussion happened around a particular question on stackoverflow, but I thought it was more appropriate to move the discussion over to here as a question to avoid cluttering up the answer on SO with this tangent since it has veered off-topic from the original question. You can look at that question and its answers for the example code snippets that got the discussion going.
Here is a simplified example:
join_type = "explicit"
a = "%s line joining" \
% (join_type)
# versus
join_type = "implicit"
b = ("%s line joining"
% (join_type))
Best Answer
There is a coding style document called PEP8. It recommends against the usage of
\<NL>
wherever parentheses can be used.Full text: http://www.python.org/dev/peps/pep-0008/ (section Code Layout)
It is not compulsory but it defines acceptable good practices which are especially useful if you have multiple Python committers on your team.