Quantcast
Channel: Why do we namespace staticmethod in Python? - Stack Overflow
Browsing latest articles
Browse All 2 View Live

Answer by Blckknght for Why do we namespace staticmethod in Python?

Methods defined in a class are not accessible by bare name, except by code running directly in the class namespace (not inside another method). If you want to call a method, you usually have to look it...

View Article


Why do we namespace staticmethod in Python?

class A(object): def __init__(self, val): self.val = A.plus_one(val) @staticmethod def plus_one(val): return val + 1We can define a static method in a class and use it in any places. My question is,...

View Article
Browsing latest articles
Browse All 2 View Live