Default parameter for a method

2008-04-16 Thread s0suk3
I wanted to know if there's any way to create a method that takes a default parameter, and that parameter's default value is the return value of another method of the same class. For example: class A: def __init__(self): self.x = 1 def meth1(self): return self.x def

Default parameter for a method... again

2008-04-16 Thread s0suk3
I had posted this before but all the spam whipped it out... I wanted to know if there's any way to create a method that takes a default parameter, and that parameter's default value is the return value of another method of the same class. For example: class A: def __init__(self

Re: Default parameter for a method... again

2008-04-16 Thread Matimus
On Apr 16, 9:26 am, [EMAIL PROTECTED] wrote: I had posted this before but all the spam whipped it out... I wanted to know if there's any way to create a method that takes a default parameter, and that parameter's default value is the return value of another method of the same class

Re: Default parameter for a method

2008-04-16 Thread Larry Bates
[EMAIL PROTECTED] wrote: I wanted to know if there's any way to create a method that takes a default parameter, and that parameter's default value is the return value of another method of the same class. For example: class A: def __init__(self): self.x = 1 def meth1(self

Re: Default parameter for a method

2008-04-16 Thread Cliff Wells
On Wed, 2008-04-16 at 13:47 -0500, Larry Bates wrote: [EMAIL PROTECTED] wrote: I wanted to know if there's any way to create a method that takes a default parameter, and that parameter's default value is the return value of another method of the same class. For example: class

Re: Default parameter for a method

2008-04-16 Thread Peter Otten
Cliff Wells wrote: On Wed, 2008-04-16 at 13:47 -0500, Larry Bates wrote: [EMAIL PROTECTED] wrote: I wanted to know if there's any way to create a method that takes a default parameter, and that parameter's default value is the return value of another method of the same class

Re: Default parameter for a method

2008-04-16 Thread John Nagle
[EMAIL PROTECTED] wrote: I wanted to know if there's any way to create a method that takes a default parameter, and that parameter's default value is the return value of another method of the same class. For example: ... def meth2(self, arg=meth1()): Not good. If the default

Re: Default parameter for a method

2008-04-16 Thread Terry Reedy
John Nagle [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | [EMAIL PROTECTED] wrote: | I wanted to know if there's any way to create a method that takes a | default parameter, and that parameter's default value is the return | value of another method of the same class. For example

Re: Default parameter for a method

2008-04-16 Thread George Sakkis
On Apr 16, 4:21 pm, John Nagle [EMAIL PROTECTED] wrote: In general, default values should be immutable constants only. This is more restrictive than necessary; it should rather read In general, default values should be *treated as* immutable objects only. It's perfectly fine for a default value