Python has some methods that are special in a way . If these methods are created inside a class, they can bring in some unique behaviors . We will talk about the method '__call__' today.
Python tutorials and tricks, concepts and exploring cool modules with extensive examples.
Search
13 March, 2019
04 March, 2019
Examples of Super method in Classes
Hi all. We are going to see some examples of usage of keyword 'super' here .
21 December, 2018
Python Global Variables
The keyword "global" has a special purpose . If you look into the help docstring of this keyword, you must notice this line :
Now . In python , if you declare a variable outside the scope of all functions or classes, it is AVAILABLE GLOBALLY. Meaning I can use it anywhere anytime.
But what is NOT clear , is , you CANNOT change the value\contents of this variable.
Bringing statefulness into your program (e.x an integrating counter ), might need you to keep updating some variable's value . That means, functions must be able to change that value.
Hence, the keyword "global" .
It would be impossible to assign to a global variable without "global "
The word to note is "Assign"
But what is NOT clear , is , you CANNOT change the value\contents of this variable.
Bringing statefulness into your program (e.x an integrating counter ), might need you to keep updating some variable's value . That means, functions must be able to change that value.
Hence, the keyword "global" .
Subscribe to:
Posts (Atom)