Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'read.': 0.03; 'matplotlib': 0.09; 'style.': 0.09; 'subject:design': 0.09; 'to:addr:comp.lang.python': 0.09; 'api': 0.11; 'cc:addr:python- list': 0.11; 'subject:Help': 0.11; 'python': 0.11; 'thread': 0.14; '"global"': 0.16; "'a',": 0.16; 'both,': 0.16; 'duplicates': 0.16; 'figure()': 0.16; 'nightmare.': 0.16; 'objects.': 0.16; 'scientists': 0.16; 'subject:API': 0.16; 'world!")': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'example': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; 'header:User- Agent:1': 0.23; 'accommodate': 0.24; 'example.': 0.24; 'helpful': 0.24; 'looks': 0.24; 'cc:no real name:2**0': 0.24; 'header:In- Reply-To:1': 0.27; 'idea': 0.28; 'point': 0.28; 'function': 0.29; 'correct': 0.29; 'michael': 0.29; "doesn't": 0.30; 'mix': 0.30; 'reply.': 0.31; '-----': 0.33; 'problem': 0.35; 'subject: (': 0.35; 'received:209.85': 0.35; 'point.': 0.35; 'received:google.com': 0.35; 'google': 0.35; 'thanks': 0.36; "i'll": 0.36; 'searching': 0.37; 'received:209.85.216': 0.37; 'received:209': 0.37; 'being': 0.38; 'window': 0.38; 'issue': 0.38; 'fact': 0.38; 'little': 0.38; 'easy': 0.60; 'march': 0.61; 'course': 0.61; "you're": 0.61; "you'll": 0.62; 'our': 0.64; 'become': 0.64; 'more': 0.64; 'great': 0.65; 'effectively': 0.66; '26,': 0.68; 'zen': 0.84; 'shell,': 0.91; '2013': 0.98 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:path:newsgroups:date:in-reply-to:complaints-to :injection-info:nntp-posting-host:references:user-agent :x-google-web-client:x-google-ip:mime-version:message-id:subject :from:to:cc:content-type:content-transfer-encoding :x-gm-message-state; bh=6Ofci0nV0F8UATZQu+WRh20GkWTpOrHqK03Mu+K42+U=; b=TKHf7QjLB5VH66Aivh+WYzFK/AVjhynPgXwVQcrCMLYAMBYzA/ScAmVmIGn4JEsbpX Ut16d1zdxneaJF90LnP8OQDeTV2Vpnua9jnosqsdSaQiz8Wn/YQWNYArkKFSDeGGctgm BkpGKKuuZXTwGQWNKs94DRy5rcWY8O7GL+TMaBeXc+6YQXUiB8YN4H85EH4DcUBMBEH0 w5Hhm1Uv+yvjpMYmAb+lNdjDMw45hprKo9tiaKLqP1/8HgjYEEkaZtMf4FVbHRHJfttE sK1t+mA1v7/7trU2pTAgr/iuxY+kB+5NRsCK3fUTLnpQIRTFFS+RzOkNqmCQkxA+OpTv aa0A== X-Received: by 10.49.24.134 with SMTP id u6mr913138qef.24.1364298769955; Tue, 26 Mar 2013 04:52:49 -0700 (PDT) Newsgroups: comp.lang.python Date: Tue, 26 Mar 2013 04:52:49 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=89.68.221.197; posting-account=oknH1QoAAABqzbD_5ziFTvLQsqNk2LbU References: <68da956e-ebe0-4f58-92cd-f7ffff0075b4@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 89.68.221.197 MIME-Version: 1.0 Subject: Re: Help me pick an API design (OO vs functional) From: Michael Herrmann To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQki/z28G+SdVS7w9poZM+oppg04NkVwd2bJTQ5mZoUyviRxzIoEbQond2uQiqlXVHoRE0+L Cc: python-list@python.org, Michael Herrmann 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: , Message-ID: Lines: 53 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364298778 news.xs4all.nl 6973 [2001:888:2000:d::a6]:33538 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41884 On Tuesday, March 26, 2013 11:07:45 AM UTC+1, Jean-Michel Pichavant wrote: > ----- Original Message ----- > > 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') > >=20 > > The problem with this design is that it effectively duplicates our > > API: We want to keep our "global" functions because they are so easy > > to read.=20 >=20 > So is the example above. This is the best solution in my opinion.=20 Thanks for your reply. What do you mean by "So is the example above" though= ?=20 > I think you're having the same issue that some other APIs, let's say matp= lotlib for example. They try to accommodate scientists (matlab) and program= mers(python) by having a double API style. >=20 > One looks like >=20 > legend() > title() > plot() > save() >=20 > the other looks like >=20 > fig =3D figure() > fig.add_legend() > fig.title() > fig.plot() > fig.save() >=20 > The problem is, when searching for example on the net, you'll end up with= a mix of both, it can become a nightmare. Interesting point. I'll google a little about matplotlib. > I definitely prefer the later, for the reasons that have already been giv= en to you in this thread and by the fact that with the correct (I)python sh= ell, you can create your window object and get auto-completion on its metho= ds just by hitting , very helpful when introspecting objects. Can be a= chieved of course in any python shell with function like dir() ; my point b= eing that OOO design keeps things in their place, see the zen of python "Na= mespaces are one honking great idea -- let's do more of those!" Doesn't the IPython do auto-completion for "global" functions?=20 Thanks, Michael (www.getautoma.com)