What is the advantage of using static methods in Python?
- by Curious2learn
I ran into unbound method error in python with the code
class Sample(object):
'''This class defines various methods related to the sample'''
def drawSample(samplesize,List):
sample=random.sample(List,samplesize)
return sample
Choices=range(100)
print Sample.drawSample(5,Choices)
After reading many helpful posts here, I figured how I could add @staticmethod above to get the code working. I am python newbie. Can someone please explain why one would want to define static methods? Or, why are not all methods defined as static methods.
Thanks in advance.