|
|
|
Hm, I hadn't ever heard of selfless before reading this post, so I am speaking strictly on the fact that I have never used it.
I fail to see the benefit of this OVER the standard self declaration. You still have to add your '@selfless' decorator to EVERY function? So you'd rather type:
class Test(object):
@selfless
def __init__(x=None):
self.x = x
...instead of:
class Test(object):
def __init__(self, x=None):
self.x=x
That seems to be a lot more work than specifically adding the self declaration...
...just my 1.3859273589409872 cents
Paul |
Homepage |
06/12/17 - 10:28 pm | #
|
|
Check the very next entry for a metaclass that automagically decorates all your methods for you.
Apart from the fact that this is obviously a frivolous hack... :-p
Fuzzyman |
Homepage |
06/12/17 - 10:40 pm | #
|
|
after many c++ years spent in
debugging classes with more than
hundred attributes,
self is actually a god sent especially
in large software:
it states clearly that is a class attribute
intead a local variable.
antonio |
06/12/19 - 10:59 am | #
|
|
(instance attribute rather than class attribute). I agree that *having* an explicit self is a very good thing. It is especially useful when refactoring, you can see which instance attributes methods use.
This silly hack doesn't remove self, it removes the need to explicitly declare it in method signatures...
Fuzzyman |
Homepage |
06/12/19 - 11:54 am | #
|
|
|
Commenting by HaloScan
|