Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python class member or global variable [closed]

When defining a Python class, class members are like global variables for the class. Then, I do not understand why global variables do exist ? Shouldn t we always use class members instead ?


1 Answers

Class members are like global variables for the class. Global variables are like class members for the module.

It's really that simple.

P.S. Just in case you are a Java programmer: yes, you can have more than one public class in your module; yes, you should use this when appropriate.

like image 190
kirelagin Avatar answered Jul 19 '26 16:07

kirelagin