Help me pick an API design (OO vs functional)

Michael Herrmann michael.herrmann at getautoma.com
Tue Mar 26 09:53:30 CET 2013


On Monday, March 25, 2013 10:08:53 PM UTC+1, Chris Angelico wrote:
> ...
> > I kind of like the context manager solution because the indentation makes it very obvious what happens in which window. You are right about our target group though. Also, the "with" is not as explicit as it probably should be.
> 
> What happens at the __exit__ of the context manager? What happens if
> context managers are nested? I'd be inclined to the simpler option of
> an explicit switch (since focus doesn't really "stack" and it'd feel
> weird for focus to *sometimes* switch away when you're done working
> with one window), though the context manager syntax does have its
> advantages too.

You are right, an __exit__ for a window doesn't really make sense and neither does stacking. There's also the problem that the focus window may change - for instance when closing it. What happens if you're still inside the "with ..." then? At first glance, I think the context manager solution looks nice syntactically, but maybe it isn't the way to go here.

> ...
> 
> > We'd of course love to support other platforms but don't currently have the resources to do this. We actually just wrote a blog entry about this and some related questions: http://www.getautoma.com/blog/automa-faq If we have something wrong, do let us know in the comments over there!
> 
> 
> Make the API clean enough and someone else might well write a Linux
> equivalent. Then it'll be as simple as a try/import/except/import at
> the top and multiple platforms will work.

Yes, that's a good point. A clean API is very important to us (hence my posting here).

Thanks for your answer!
Michael



More information about the Python-list mailing list