duncan smith wrote:
> On 02/12/2018 18:36, Peter Otten wrote:
>> class CommonMethods:
>> __add__ = add
> Ah, I could just bind them within the class,
>
> mean = mean
> max = max etc.
>
> but I'd somehow convinced myself that didn't work. As the names are the
> same I'd probably sti
On 02/12/2018 18:36, Peter Otten wrote:
> duncan smith wrote:
>
>> Hello,
>> I have a lot of functions that take an instance of a particular
>> class as the first argument. I want to create corresponding methods in
>> the class. I have tried the following, which (when called from __init__)
>
On 02/12/2018 18:56, duncan smith wrote:
> Hello,
> I have a lot of functions that take an instance of a particular
> class as the first argument. I want to create corresponding methods in
> the class. I have tried the following, which (when called from __init__)
> creates the relevant method
On 02/12/2018 18:26, Stefan Ram wrote:
> duncan smith writes:
>> I have tried to find examples of injecting methods into classes without
>
> Wouldn't the normal approach be to just define a
> class with your functions as instance methods?
>
> main.py
>
> class C():
> def __init__( sel
duncan smith wrote:
> Hello,
> I have a lot of functions that take an instance of a particular
> class as the first argument. I want to create corresponding methods in
> the class. I have tried the following, which (when called from __init__)
> creates the relevant methods in an instance (Py
Hi Duncan.
On Sun, Dec 2, 2018 at 7:02 PM duncan smith wrote:
> Hello,
> I have a lot of functions that take an instance of a particular
> class as the first argument. I want to create corresponding methods in
> the class. I have tried the following, which (when called from __init__)
> cre
Hello,
I have a lot of functions that take an instance of a particular
class as the first argument. I want to create corresponding methods in
the class. I have tried the following, which (when called from __init__)
creates the relevant methods in an instance (Python 3.6).
def init_methods(s