Help me pick an API design (OO vs functional)

Neil Cerutti neilc at
Tue Mar 26 18:25:41 CET 2013

On 2013-03-26, Dave Angel <davea at> wrote:
> On 03/26/2013 10:40 AM, Michael Herrmann wrote:
>> On Tuesday, March 26, 2013 3:13:30 PM UTC+1, Neil Cerutti wrote:
>>>    <SNIP>
>>> Have you considered adding a keyword argument to each of your
>>> global functions, which is normally None, but allows a user to
>>> provide a prefered focus window?
>>> enter_text("test.txt", focus=save_dialog)
>>> press_button(Savebutton, focus=save_dialog)
>> It's an interesting new idea but I somehow feel it makes the existing functions too complicated. Also, having to add it to all existing, and future functions sounds a bit too cumbersome to me.
> Perhaps Neil didn't make it clear enough.  I figure he meant a keyword 
> argument with an explicit default value of None.  (or if you followed my 
> earlier discussion, default value of focused)
> That way your user can keep using the functions for when there's no 
> ambiguity, but add a focus= parameter only when needed.
> To go back to my sample wrapper functions, they'd look something like 
> (untested):
> def write(*args, focus=focused):
>      focus.write(*args)
> Of course, the user should only use the wrappers when things
> are sure to remain "simple."

Yes, along those lines. Most code would never need to provide the
focus= keyword. Only when setting focus in a weird way would it
be needed.

Neil Cerutti

More information about the Python-list mailing list