Answer the question
In order to leave comments, you need to log in
How should variables and functions be named in Python?
1) Is it worth using variables with such common names: result, data, final?
def foo(questions):
result = []
for question in questions:
data = question
result.append(data)
return result
for ticket in tickets:
....
for question in questions:
.....
first_question_from_ticket = data[0]
def get_question_from_string():
.....
Answer the question
In order to leave comments, you need to log in
> I will be glad to links to resources with Best Practices on this topic)
https://www.python.org/dev/peps/pep-0008/
1. Yes. They are in the context of the method.
2. Yes.
3. Only if it is not clear in the context of the method. Make it clear and avoid such names.
well, in general, https://www.python.org/dev/peps/pep-0020/
By the way, on the third point - while participating in one project on eiffel, I managed to get tired of such verbosity. I will only add to the previous post that it is always better to avoid this and compensate with comments
In general, the code should be written as if you will open it in 10 years. Introduced?
If there are some nuances, you still won’t remember them.
1) Functions must be called imperatively (imperative mood).
2) Use namespaces.
открыть_ёжика_левого
открыть_ёжика_правого
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question