like in PHP you can do
class C { private const FOO=123; } for constants that are only relevant inside the class/not part of the public API, does Python support something similar?
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about CollectivesStack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Explore Stack Internallike in PHP you can do
class C { private const FOO=123; } for constants that are only relevant inside the class/not part of the public API, does Python support something similar?
@propertymethod decorator to make the value read only (i.e. a constant),@property def __foo(self): return 123@property(i.e. a getter without a setter) is not the same asconst, though for many use cases the behaviour will be similar__isn't really private either, so you can always get around these limitations in some way.