Quantcast
Channel: Why do we namespace staticmethod in Python? - Stack Overflow
Browsing index pages (2 articles)
↧

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


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

Browsing index pages (2 articles)


Latest Images