Help me pick an API design (OO vs functional)

Michael Herrmann michael.herrmann at
Tue Mar 26 15:40:03 CET 2013

On Tuesday, March 26, 2013 3:13:30 PM UTC+1, Neil Cerutti wrote:
> On 2013-03-25, Mitya Sirenef wrote:
> > I think I would prefer context managers. I don't think it's a
> > big problem for win users because this behaviour would be one
> > of the first things documented in the start guide and would be
> > all over example scripts, so a new user missing or forgetting
> > it is not a realistic scenario.
> If window focus switching is really a rarity, and only done
> briefly then I agree that a context manager makes a nice and neat
> solution.
> But it's too powerful a generalisation for such a small corner
> case.
> 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. 

> (Those are just guesses at your API functions; sorry.)

No worries! Thank you for your suggestion!


More information about the Python-list mailing list