On Sun, Jan 31, 2010 at 3:43 AM, Terry Brown <[email protected]> wrote:

> For anyone wondering, quickMove.py supports 11 similar ways of creating 
> buttons to move nodes to other nodes, and rather than have 11 stub methods of 
> the form:
>
> def moveToFirstChild(...):  doSomething(self.target, type_='move', first=True)
> def moveToLastChild(...):   doSomething(self.target, type_='move', 
> first=False)
> def copyToFirstChild(...):  doSomething(self.target, type_='copy', first=True)
> def copyToLastChild(...):   doSomething(self.target, type_='copy', 
> first=False)
> def cloneToFirstChild(...): doSomething(self.target, type_='clone', 
> first=True)
> def cloneToLastChild(...):  doSomething(self.target, type_='clone', 
> first=False)

What I'm thinking is, methods should always be spelled out explicitly
in the class declaration.

You can manufacture callables easily by instantiating a class that
provides __call__(), or by using closures (my preferred method).
Creating real instancemethods and monkeypatching them to an existing
class sort of obscures the intention (and messes with the magical side
of python).

-- 
Ville M. Vainio
http://tinyurl.com/vainio

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to