Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'explicit': 0.07; 'subject:design': 0.09; 'wrong,': 0.09; 'api': 0.11; 'cc:addr :python-list': 0.11; 'subject:Help': 0.11; 'windows': 0.15; "'a',": 0.16; 'gpg': 0.16; 'imo.': 0.16; 'prefer.': 0.16; 'pythonistas': 0.16; 'sense,': 0.16; 'subject:API': 0.16; 'world!")': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'helpful': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'michael': 0.29; 'respective': 0.29; 'message- id:@mail.gmail.com': 0.30; '25,': 0.31; 'could': 0.34; 'subject: (': 0.35; 'something': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'library.': 0.36; 'url:org': 0.36; 'should': 0.36; 'changing': 0.37; 'too': 0.37; 'version,': 0.38; 'pm,': 0.38; 'extremely': 0.39; 'users': 0.40; 'how': 0.40; 'most': 0.60; 'mar': 0.68; 'ps.': 0.84; 'ugly,': 0.84; 'don\xe2\x80\x99t': 0.91; 'url:tk': 0.95; 'opt': 0.97; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=dpGW4B11AcMiUdZIKoj9bdQEksUO4s/eRu6Xqxyi+V0=; b=Eyz+xaP2K+OXwoJ3if2XgVwej/ZcwU8Fs3oawC3+XufTg2W3UeFH8wx/PCymJt+ASI LIwxCWCHa955WkgEanksdlGk0dgYaW4EdnXyfEzakPmAG+ISHqVuyrxj8tM9NhS1YSM6 tTvy+4RNGn8UllBLIyfm0ahloCqsJXMcS/Fvw9vbDnw+sZ1beeicdVrgQog4nCtm0vge dNt6l1gDfmyMzm7dpMd+v2tvzafGv1xuQOG+NB6HbRiGYQ2/Tdpixu+siWKtU541x6YS 5Fi/xiiNP71NtS6tMXdgp8sE16xBDW6KBzaqTo6hKWDTCu8YDZb6lzQzG7OGaATCEa0L y4pQ== X-Received: by 10.50.17.71 with SMTP id m7mr8844234igd.14.1364240566211; Mon, 25 Mar 2013 12:42:46 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <68da956e-ebe0-4f58-92cd-f7ffff0075b4@googlegroups.com> References: <68da956e-ebe0-4f58-92cd-f7ffff0075b4@googlegroups.com> From: Kwpolska Date: Mon, 25 Mar 2013 20:42:25 +0100 Subject: Re: Help me pick an API design (OO vs functional) To: Michael Herrmann Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org 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: 58 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364240574 news.xs4all.nl 6929 [2001:888:2000:d::a6]:52742 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41828 On Mon, Mar 25, 2013 at 8:29 PM, Michael Herrmann wrote: > notepad_1 =3D start("Notepad") > notepad_2 =3D start("Notepad") > notepad_1.write("Hello World!") > notepad_1.press(CTRL + 'a', CTRL + 'c') > notepad_2.press(CTRL + 'v') Explicit is better than implicit. Changing windows should be explicit and not implified by your library. > notepad_1 =3D start("Notepad") > notepad_2 =3D start("Notepad") > switch_to(notepad_1) > write("Hello World!") > press(CTRL + 'a', CTRL + 'c') > switch_to(notepad_2) > press(CTRL + 'v') Much better. > 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=E2=80=99s ugly, and don=E2=80=99t forget that your users aren=E2=80=99= t Pythonistas most of the time. > notepad_1 =3D start("Notepad") > notepad_2 =3D start("Notepad") > notepad_1.activate() > write("Hello World!") > press(CTRL + 'a', CTRL + 'c') > notepad_2.activate() > press(CTRL + 'v') That is nice and makes sense, because a global function feels wrong, at least for me. > It would be extremely helpful for us if you could let me know which way o= f using the API you would prefer. If you opt for an explicit version, how w= ould you call the respective method? "activate" / "switch_to" / "focus" or = something else? Window().focus() is the best IMO. PS. do you plan a version for non-Windows OSes? Also, =E2=82=AC99 is too e= xpensive. --=20 Kwpolska | GPG KEY: 5EAAEA16 stop html mail | always bottom-post http://asciiribbon.org | http://caliburn.nl/topposting.html