On Tue, Aug 8, 2017 at 2:39 AM, Alan Gauld via Tutor wrote:
> On 08/08/17 02:22, boB Stepp wrote:
[snip lots of good stuff]
I am coming to the conclusion I need to code a substantial,
challenging project using OOP techniques, instead of just the toy
programs I have been playing around with so fa
On 08Aug2017 08:39, Alan Gauld wrote:
(1) There are very, very few good uses for static methods in Python. If
you think you need a static method, you probably could just use a
regular module-level function.
Amen to that, I try to avoid staticmethods... and so far
have never found a valid use f
Alan Gauld via Tutor wrote:
> classes are objects too...
Also, classes are instances. Given
>>> class Foo:
... pass
...
>>> foo = Foo()
>>> type(foo)
>>> type(Foo)
what is the type of the type of the type ... of foo?
The answer is a circular definition that you cannot spell in Python its
On 08/08/17 02:22, boB Stepp wrote:
> "@staticmethod" then there are two ways of calling the method, using
> objects or using the class. Is there some reason not to use the
> "ClassName.a_static_method()" syntax? Are there intended uses for
> doing this?
classes are objects too...
You could ha
On 07Aug2017 20:22, boB Stepp wrote:
On Mon, Aug 7, 2017 at 8:36 AM, Steven D'Aprano wrote:
[...]
It is hard to see the distinction between an ordinary method and a
static method from this example. What you are seeing is, by accident,
the equivalent of just writing:
def my_method():
prin
I feel like I have gazed into a crystal clear pool, apparently
shallow, with many interesting objects (Pun intended!) on the pool
floor. Interested in these beautiful things, I jump in to grab one
for close-up study only to find that the pool is much, ... , much
deeper (> 1 boB-height) than it app
On Sun, Aug 06, 2017 at 06:35:10PM -0500, boB Stepp wrote:
> py3: class MyClass:
> ... def my_method():
> ... print('This is my_method in MyClass!')
> ...
> py3: class MyOtherClass:
> ... @staticmethod
> ... def my_other_method():
> ... print('This is my_other_m
On Sun, Aug 6, 2017 at 11:35 PM, boB Stepp wrote:
>
> I see no difference in result, whether I use the @staticmethod decorator or
> not.
While a staticmethod and a function are both descriptors [1], a
staticmethod is basically a no-op descriptor. Its __get__ method
always returns its unbound cal
On 07/08/17 00:35, boB Stepp wrote:
> =
> Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64
> bit (AMD64)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> p
I am looking more deeply into the subject of decorators for a bit (So
I can thoroughly digest Steve's information in the thread "basic
decorator question".) and have been first looking at static and class
methods. As a start, I have tried the following:
===
10 matches
Mail list logo