The derived Model class originally used a staticmethod decorator for the fibonacci() function,
but the book doesn't discuss why. (The regular Python docs really don't describe staticmethod very clearly, either)
When I changed the decorated function to a class method, the program works
the same, from what I can see.
I'm curious what value the decorator was supposed to add, in this case.
Thanks
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris....@noaa.gov
--
You received this message because you are subscribed to a topic in the Google Groups "wxPython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/OAInMcKm6oI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wxpython-user...@googlegroups.com.
If a function can be called without the Le and instance, then what value is their having it in the class at all?This looks like a friend in C++, which just tears the OO walls apart.
C:\Users\timr>type x.py
class Foo(object):
# A class member variable:
count = 0
def __init__(self):
Foo.count += 1
@classmethod
def getcount(cls):
return cls.count
x = Foo()
y = Foo()
z = Foo()
print( x.getcount() )
print( Foo.getcount() )
C:\Users\timr>python x.py
3
3
C:\Users\timr>
Why should a "callable"be part of a class , if it can be called without reference to the instance ?
-- Tim Roberts, ti...@probo.com Providenza & Boekelheide, Inc.
If a function can be called without the Le and instance, then what value is their having it in the class at all?This looks like a friend in C++, which just tears the OO walls apart.
It's not like "friend" at all. It's closer to a C++ static method. The @classmethod is declared within the class, and has access to the class variables.
On Thu, May 11, 2017 at 10:05 AM, Tim Roberts <ti...@probo.com> wrote:If a function can be called without the Le and instance, then what value is their having it in the class at all?This looks like a friend in C++, which just tears the OO walls apart.
It's not like "friend" at all. It's closer to a C++ static method. The @classmethod is declared within the class, and has access to the class variables.
I remember some other more clever uses for classmethod (w/__metaclass_) that I had used in Editra in the past but been long enough my memory is getting fuzzy on the details. (like creating smart factory methods, ect..)