-2

Is there a naming convention for module variables/functions that are local versus exported? For example: DEBUG = True # Uppercase for local variables do_something(): exported for outside use

Kal
  • 21
  • 4
  • 3
    Maybe you should read [PEP 8](https://www.python.org/dev/peps/pep-0008/) – Corralien Sep 14 '21 at 20:33
  • uppercase variable by convention is a global constant (meaning it is defined in the global scope and its value doesn't change during runtime (not sure if ever, but they are not meant to be changing often at least, if at all (by convetion))) – Matiiss Sep 14 '21 at 20:55
  • Please provide enough code so others can better understand or reproduce the problem. – Community Sep 21 '21 at 19:16

1 Answers1

0

Read PEP 8

Uppercase variables are for universal constants such as PI or INCHES_PER_FOOT

Protected variable are variables that start with a underscore, such as _protected_variable and are used on methods, functions, and variables that are meant for internal use only.

Private variables are like protected variables but python will enforce the restricted access. They start with two underscores.

Lukas
  • 31
  • 2
  • 1
    "Private variables are like protected variables but python will enforce the restricted access. They start with two underscores." Sort of. It's a little more complicated than that. https://stackoverflow.com/a/68510452/13990016 – Alex Waygood Sep 14 '21 at 23:05
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-ask). – Community Sep 15 '21 at 00:16