Decorating one method of a class C with another method of class C?
Dan Stromberg
drsalists at gmail.com
Sun Jun 8 14:04:15 EDT 2014
On 6/6/14, Ben Finney <ben at benfinney.id.au> wrote:
> Dan Stromberg <drsalists at 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?
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 "reconnected_to_server_if_needed".
I'll probably end up putting a try/except in each simple operation,
making them a bit less simple.
More information about the Python-list
mailing list