I recently bought a book called "Black Hat Python". However, I found that some variables are only made out of uppercase and the book was using it like a global variable. Is there any feature in python that globalize variable by making a variable with only upper cases?
CodePudding user response:
As of now, there is no such method. Rather you could define a global variable using the global
keyword.
Here is an example:
def myfunction():
global s
s = ' Hello World'
print(s)
s = "I love python"
print(s)
# Global Scope
s = "Python is great!"
f()
print(s)
You can refer to this link for reference - link
CodePudding user response:
There is no any difference for python how you set your variable. Uppercase may be used just for visual explanation.
You can read more about it via link: