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


Groups > comp.lang.python > #72994

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

From Ben Finney <ben@benfinney.id.au>
Subject Re: Decorating one method of a class C with another method of class C?
Date 2014-06-09 07:19 +1000
References <CAGGBd_pM5DGp85LVfeQgYwqS8DU8nuQL8Q8G5EzfQ5BX26fa-w@mail.gmail.com> <85lht91s30.fsf@benfinney.id.au> <CAGGBd_qiaw5jahp8QTkc0R+pz3RRvo6c_QTgXZ=ZdrOnvEv++w@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.10901.1402262405.18130.python-list@python.org> (permalink)

Show all headers | View raw


Dan Stromberg <drsalists@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 original post correctly, does not need the class nor the class
instance. So you can define that function outside the class, and use it
for decorating methods within the class.

-- 
 \     “Teach a man to make fire, and he will be warm for a day. Set a |
  `\       man on fire, and he will be warm for the rest of his life.” |
_o__)                                                 —John A. Hrastar |
Ben Finney

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Decorating one method of a class C with another method of class C? Ben Finney <ben@benfinney.id.au> - 2014-06-09 07:19 +1000

csiph-web