I agree with you Steven that the OP should avoid __getattribute__ and
the like for many a thing. I also agree with your last statement. I
try to answer the OP's question without much You shouldn't do this's
and don't do that's. I trust them to make thier own decisions. I'd
say A much better
There's some_object.some_method.func_defaults and
some_function.func_defaults both are a settable attribute. How to set
the methods func_defaults? You'd have to have code in
_getattribute__(yourmethod) if not __getattr__(yourmethod)
def __getattribute__(self, attr):
if attr == self.my_method:
On Thu, 30 Dec 2010 11:26:50 -0800, DevPlayer wrote:
There's some_object.some_method.func_defaults
Not quite -- method objects don't expose the function attributes
directly. You need some_object.some_method.im_func to get the function
object, which then has a func_defaults attribute.
and
On Monday 13 December 2010, 18:14:27 Godson Gera wrote:
On Sun, Dec 12, 2010 at 5:05 PM, ernest nfdi...@gmail.com wrote:
Hi,
I'd like to have a reference to an instance attribute as
default argument in a method. It doesn't work because
self is not defined at the time the method
On Wed, 15 Dec 2010 21:10:05 +0100, Hans-Peter Jansen wrote:
Since this is a major pitfall, it might be worth mentioning, that
mutable default arguments are generally a bad idea, as the default
arguments are evaluated just once, hence e.g. using an empty list might
contain the items, that
On Thursday 16 December 2010, 00:56:31 Steven D'Aprano wrote:
On Wed, 15 Dec 2010 21:10:05 +0100, Hans-Peter Jansen wrote:
Since this is a major pitfall, it might be worth mentioning, that
mutable default arguments are generally a bad idea, as the default
arguments are evaluated just once,
ernest wrote:
Hi,
I'd like to have a reference to an instance attribute as
default argument in a method. It doesn't work because
self is not defined at the time the method signature is
evaluated. For example:
class C(object):
def __init__(self):
self.foo = 5
def m(self, val
On Sun, Dec 12, 2010 at 5:05 PM, ernest nfdi...@gmail.com wrote:
Hi,
I'd like to have a reference to an instance attribute as
default argument in a method. It doesn't work because
self is not defined at the time the method signature is
evaluated. For example:
class C(object):
def
On 12/13/2010 12:14 PM, Godson Gera wrote:
On Sun, Dec 12, 2010 at 5:05 PM, ernest nfdi...@gmail.com
mailto:nfdi...@gmail.com wrote:
Hi,
I'd like to have a reference to an instance attribute as
default argument in a method. It doesn't work because
self is not defined
Hi,
I'd like to have a reference to an instance attribute as
default argument in a method. It doesn't work because
self is not defined at the time the method signature is
evaluated. For example:
class C(object):
def __init__(self):
self.foo = 5
def m(self, val=self.foo
On Sun, Dec 12, 2010 at 3:35 AM, ernest nfdi...@gmail.com wrote:
Hi,
I'd like to have a reference to an instance attribute as
default argument in a method. It doesn't work because
self is not defined at the time the method signature is
evaluated. For example:
class C(object):
def
11 matches
Mail list logo