-1

I searched a lot for static variables in python but could not find a direct answer . Just as java would have a variable defined as static within a class , can the same be done for python?

Divyang Shah
  • 3,577
  • 5
  • 14
  • 27

2 Answers2

0

For using static variable you have to use it inside class.

 class XYZ:
     value = 3


 print(MyClass.value) //  access it via class name
Jitesh Mohite
  • 31,138
  • 12
  • 157
  • 147
0

How's

class A(object):
    v = 123

You access it simply as

A.v