-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
  • 2,447
  • 4
  • 13
  • 23

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
  • 24,460
  • 12
  • 119
  • 117
0

How's

class A(object):
    v = 123

You access it simply as

A.v