Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder1.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'syntax': 0.04; 'context': 0.07; 'explicit': 0.07; 'subject:design': 0.09; 'window.': 0.09; 'wrong,': 0.09; 'url:blog': 0.10; 'api': 0.11; 'subject:Help': 0.11; 'wrote': 0.14; '"with"': 0.16; "'a',": 0.16; 'aren\x92t': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inclined': 0.16; 'pythonistas': 0.16; 'subject:API': 0.16; 'there!': 0.16; 'world!")': 0.16; 'weird': 0.16; 'wrote:': 0.18; 'platforms': 0.22; 'questions:': 0.24; 'simpler': 0.24; 'switch': 0.26; 'header:In-Reply-To:1': 0.27; 'michael': 0.29; "we'd": 0.29; 'am,': 0.29; 'related': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; 'work.': 0.31; 'comments': 0.31; 'too.': 0.31; '(since': 0.31; '25,': 0.31; 'equivalent.': 0.31; 'indentation': 0.31; 'though.': 0.31; 'this.': 0.32; 'probably': 0.32; 'option': 0.32; 'linux': 0.33; 'monday,': 0.33; "i'd": 0.34; 'subject: (': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'really': 0.36; 'done': 0.36; 'entry': 0.36; 'should': 0.36; 'too': 0.37; 'manager': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'users': 0.40; 'most': 0.60; 'managers': 0.61; 'march': 0.61; 'course': 0.61; 'simple': 0.61; "you're": 0.61; 'kind': 0.63; 'our': 0.64; 'love': 0.65; 'charset:windows-1252': 0.65; 'mar': 0.68; '26,': 0.68; 'advantages': 0.68; 'obvious': 0.74; "it'd": 0.84; 'p.s.:': 0.84; 'ps.': 0.84; 'ugly,': 0.84; 'good,': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type:content-transfer-encoding; bh=ScQGRarUO6KDe9KA5NrbCFE3AWFm5SoygiImPj+Nr/4=; b=XnuaCbVw+A6ybt+JYSga4/dd8NKitZub1pukJKytKnl0Qvy0jRtomPgZJPo02FFs0Q FJf1ot1fWyWDUyxnJuiF29uBD+Kskt8f2l/KLGaaaji4FXtWcJEOacu6WNSjp6ZLsPIV uG+ZoB3TwiSGtkbRYT7AfWkGpyIT0ysWIJaJBY1wBDkz/MXZsG1tbIA7dwDJjXilCt76 7S+s4VYwSTPFjgFKb1BhaJAUJ5COzH/5BZ0EHfNEwPJvZnceUpadWLLULCTXf4031r7x J8PZNuUK8/+tBisJeLvfy3bIrSByvkTQzvMvqOgBDoDZI4Whv1dlVO/a+n6llVMmQz0n doPA== MIME-Version: 1.0 X-Received: by 10.58.75.46 with SMTP id z14mr17363509vev.52.1364245733657; Mon, 25 Mar 2013 14:08:53 -0700 (PDT) In-Reply-To: <4b2d2295-cffd-4965-8d75-ebd4f0b9da32@googlegroups.com> References: <68da956e-ebe0-4f58-92cd-f7ffff0075b4@googlegroups.com> <4b2d2295-cffd-4965-8d75-ebd4f0b9da32@googlegroups.com> Date: Tue, 26 Mar 2013 08:08:53 +1100 Subject: Re: Help me pick an API design (OO vs functional) From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364245741 news.xs4all.nl 6943 [2001:888:2000:d::a6]:48365 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41833 On Tue, Mar 26, 2013 at 7:48 AM, Michael Herrmann wrote: > On Monday, March 25, 2013 8:42:25 PM UTC+1, Kwpolska wrote: >> ... >> >> > notepad_1 =3D start("Notepad") >> > notepad_2 =3D start("Notepad") >> > with notepad_1: >> > write("Hello World!") >> > press(CTRL + 'a', CTRL + 'c') >> > with notepad_2: >> > press(CTRL + 'v') >> >> That=92s ugly, and don=92t forget that your users aren=92t Pythonistas m= ost >> of the time. > > 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 targ= et 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. >> PS. do you plan a version for non-Windows OSes? Also, =8099 is too expe= nsive. > > We'd of course love to support other platforms but don't currently have t= he 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 hav= e 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. > P.S.: First-time bottom-posting! Congrats! Feels good, doesn't it :) ChrisA