In python, there is no way to differentiate between arguments, local variables, and global variables. The easy way to do so might be have some coding convention such as
- Global variables start with _ and capital letter
- arguments end with with _
_Gvariable = 10 def hello(x_, y_): z = x_ + y_
Is this a Pythonian way to go? I mean, is there well established/agreed coding-standards to differentiate them in python?
=== ADDED ===
I just want to discriminate between arguments and local variables. As arguments are given from outside, and more like a ROM in the sense that it is not assumed to be read only. C++ provides the const keyword to prevent the arguments from changing, but not for python. I thought appending _ can be one of a way to mimic this feature in python.
I would do all your python programming according to PEP 8 guidelines. Anyone who has to read your code will thank you for it.
Why is there a need to distinguish between arguments and local variables, since one is merely a subset of the other. You can use
vars() to view scope if you are having local-global issues. The
inspect module can help with that, too. And if possible, avoid using global variables as much as possible.