Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #72989 > unrolled thread

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

Started byDan Stromberg <drsalists@gmail.com>
First post2014-06-08 11:04 -0700
Last post2014-06-08 11:04 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Decorating one method of a class C with another method of class C? Dan Stromberg <drsalists@gmail.com> - 2014-06-08 11:04 -0700

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

FromDan Stromberg <drsalists@gmail.com>
Date2014-06-08 11:04 -0700
SubjectRe: Decorating one method of a class C with another method of class C?
Message-ID<mailman.10897.1402251131.18130.python-list@python.org>
On 6/6/14, Ben Finney <ben@benfinney.id.au> wrote:
> Dan Stromberg <drsalists@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.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web