This question is pretty general, but I like to understand the good coding methods in python more ...
I would like to define a constant that I can use internally in any function without passing it as an argument, and without having to change it after the declaration - it might be nice to make it impossible, but not sure if I can do it.
What would be the best way to do this in terms of programming style (coding, naming convention, etc.).
i.e., GLOBAL_CONSTANT = 'this_variable_will_not_be_changed'
My python code will have this form, good style too?
import sys
import os
GLOBAL_CONSTANT='this_variable_will_not_be_changed'
def test():
print GLOBAL_CONSTANT
return 0
def main():
test()
return 0
if __name__ == "__main__":
main()
source
share