Answer the question
In order to leave comments, you need to log in
Should global variables be written in capital letters in regular scripts?
There is for example the simplest script from Lutz. If you run it through pylint, it swears that the variables are global and let's write them large. But this kind of script, for some reason, cuts the eye very much
#!/usr/bin/env python3
""" Small test program for while cycle """
while True:
REPLY = input('Enter text:')
if REPLY == 'stop':
break
try:
NUM = int(REPLY)
except:
print('Bad!' * 8)
else:
if NUM < 20:
print('low')
else:
print(int(REPLY) ** 2)
print('Bye!')
Answer the question
In order to leave comments, you need to log in
What if this block of code is wrapped in:
def main():
while True:
# do something
if __name__ == '__main__':
main()
REPLY = input('Enter text:')
This variable, by definition, does not fit a constant, therefore, it is an ordinary variable and it is still worth writing as_ordinary_variable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question