I am lacking in understanding of the @staticmethod property.
Explanation(s)/links might be helpful. I have not found the descriptions
found in the Internet wild to be particularly instructive. Given the code
below:
=====8<------------------
from collections import namedtuple
class Foo():
Dimensions = namedtuple('Dimensions', ['height', 'width'])
_dimensions = Dimensions(3, 4)
def dimensions():
print('id = {}'.format(id(Foo._dimensions)))
return Foo._dimensions
@staticmethod
def dimensions1():
print('id = {}'.format(id(_dimensions)))
return _dimensions
=====8<------------------
The class method Foo.dimensions() is capable of accessing class members,
but Foo.dimensions1() cannot. What does the @staticmethod decorator really
add?
Thanks!
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor