Help me pick an API design (OO vs functional)

Michael Herrmann michael.herrmann at
Wed Mar 27 13:23:57 CET 2013

On Wednesday, March 27, 2013 12:44:49 PM UTC+1, Chris Angelico wrote:
> ...
> Not seeking to advocate this particular option, but it would be
> possible to make a single wrapper for all your functions to handle the
> focus= parameter:
> def focusable(func):
> 	@functools.wraps(func)
> 	def wrapper(*args,focus=None):
> 		if focus: focus.activate()
> 		return func(*args)
> 	return wrapper
> Then you just decorate all your functions with that:
> def write(string):
>     # do something with the active window

Hi, sure, I wouldn't have copy-pasted the code and of course there are techniques to avoid code duplication. It's not so much what I'm worried about. What I'm worried about is that the concept of window-switching gets "smeared" over several other not-really related concepts such as clicking and typing. I feel it violates orthogonality: is the best freely available resource I could find but I think it's best explained in The Pragmatic Programmer


More information about the Python-list mailing list