Given that there are no real constants in Python, the convention is to name them in CAPS for conveying the intentions.
In following sample code, FIRST
and SECOND
are constants:
def fibonacci_generator(count):
FIRST, SECOND = 0, 1
a, b = FIRST, SECOND
for _ in range(count):
yield a
a, b = b, a + b
print(list(fibonacci_generator(10)))
But for the two constants, PyCharm is giving warning as:
Variable in function should be lowercase
Is there any other correct way to define constants within functions? (Without suppressing the PyCharm warning)