Re: Decorating one method of a class C with another method of class C?

2014-06-08 Thread Dan Stromberg
On 6/6/14, Ben Finney b...@benfinney.id.au wrote: Dan Stromberg drsali...@gmail.com writes: Is there a way of decorating method1 of class C using method2 of class C? Can you give a concrete example (i.e. not merely hypothetical) where this would be a useful feature (i.e. an actual

Re: Decorating one method of a class C with another method of class C?

2014-06-08 Thread Chris Angelico
On Mon, Jun 9, 2014 at 4:04 AM, Dan Stromberg drsali...@gmail.com wrote: I have a class that's operating on a socket. I'd like to have simple operations on that socket like list configured hosts, allow connection to host, etc. And I'd like them to be decorated with

Re: Decorating one method of a class C with another method of class C?

2014-06-08 Thread Ben Finney
Dan Stromberg drsali...@gmail.com writes: I'd like to have simple operations on that socket like list configured hosts, allow connection to host, etc. And I'd like them to be decorated with reconnected_to_server_if_needed. The ‘reconnected_to_server_if_needed’ method, if I understand your

Decorating one method of a class C with another method of class C?

2014-06-06 Thread Dan Stromberg
Is there a way of decorating method1 of class C using method2 of class C? It seems like there's a chicken-and-the-egg problem; the class doesn't seem to know what self is until later in execution so there's apparently no way to specify @self.method2 when def'ing method1. --

Re: Decorating one method of a class C with another method of class C?

2014-06-06 Thread Chris Angelico
On Sat, Jun 7, 2014 at 10:14 AM, Dan Stromberg drsali...@gmail.com wrote: Is there a way of decorating method1 of class C using method2 of class C? It seems like there's a chicken-and-the-egg problem; the class doesn't seem to know what self is until later in execution so there's apparently

Re: Decorating one method of a class C with another method of class C?

2014-06-06 Thread Ben Finney
Dan Stromberg drsali...@gmail.com writes: Is there a way of decorating method1 of class C using method2 of class C? Can you give a concrete example (i.e. not merely hypothetical) where this would be a useful feature (i.e. an actual improvement over the absence of the feature), and why? It

Re: Decorating one method of a class C with another method of class C?

2014-06-06 Thread Terry Reedy
On 6/6/2014 8:14 PM, Dan Stromberg wrote: Is there a way of decorating method1 of class C using method2 of class C? It seems like there's a chicken-and-the-egg problem; the class doesn't seem to know what self is until later in execution so there's apparently no way to specify @self.method2

Re: Decorating one method of a class C with another method of class C?

2014-06-06 Thread Steven D'Aprano
On Fri, 06 Jun 2014 17:14:54 -0700, Dan Stromberg wrote: Is there a way of decorating method1 of class C using method2 of class C? Yes. See below. It seems like there's a chicken-and-the-egg problem; the class doesn't seem to know what self is until later in execution so there's apparently