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

Ben Finney ben at benfinney.id.au
Sun Jun 8 17:19:37 EDT 2014


Dan Stromberg <drsalists at 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




More information about the Python-list mailing list