@jefsummers - there is no need of line 4 in this example
IF it is really waranted to have a constant, as per PEP8 recommendation, it should be ALL_CAPS:
@pjfarley3, some of your your "examples" under 1 and 2 MAY be a case to use a constant or enumeration. Some of the examples in 1 and 2 are definitely NOT such case - e.g. index numbers for elements in a list (i.e. if you want meaningful names, not int index, work with dict or named tuple). item 3 in the list is exactly why using globals should be avoided - changing variable at different scope levels is recipe for disaster and will cost you a lot of debugging time sooner than later. If we take the example you give - current position of a player, most probably you will have a Player class and it will have current_position attribute if needed, but definitely not a global variable.
IF it is really waranted to have a constant, as per PEP8 recommendation, it should be ALL_CAPS:
Quote:Constants
Constants are usually defined on a module level and written in all capital letters with underscores separating words. Examples include MAX_OVERFLOW and TOTAL.
@pjfarley3, some of your your "examples" under 1 and 2 MAY be a case to use a constant or enumeration. Some of the examples in 1 and 2 are definitely NOT such case - e.g. index numbers for elements in a list (i.e. if you want meaningful names, not int index, work with dict or named tuple). item 3 in the list is exactly why using globals should be avoided - changing variable at different scope levels is recipe for disaster and will cost you a lot of debugging time sooner than later. If we take the example you give - current position of a player, most probably you will have a Player class and it will have current_position attribute if needed, but definitely not a global variable.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs