Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41883

Re: Help me pick an API design (OO vs functional)

X-Received by 10.224.110.68 with SMTP id m4mr8816824qap.2.1364298770247; Tue, 26 Mar 2013 04:52:50 -0700 (PDT)
X-Received by 10.49.24.134 with SMTP id u6mr913138qef.24.1364298769955; Tue, 26 Mar 2013 04:52:49 -0700 (PDT)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!t2no17315606qal.0!news-out.google.com!k8ni10926qas.0!nntp.google.com!t2no17315601qal.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Tue, 26 Mar 2013 04:52:49 -0700 (PDT)
In-Reply-To <mailman.3727.1364292472.2939.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=89.68.221.197; posting-account=oknH1QoAAABqzbD_5ziFTvLQsqNk2LbU
NNTP-Posting-Host 89.68.221.197
References <68da956e-ebe0-4f58-92cd-f7ffff0075b4@googlegroups.com> <mailman.3727.1364292472.2939.python-list@python.org>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <dd54c915-9c81-4fa2-8b4a-99e8b45a2f5d@googlegroups.com> (permalink)
Subject Re: Help me pick an API design (OO vs functional)
From Michael Herrmann <michael.herrmann@getautoma.com>
Cc Michael Herrmann <michael.herrmann@getautoma.com>, python-list@python.org
Injection-Date Tue, 26 Mar 2013 11:52:50 +0000
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Xref csiph.com comp.lang.python:41883

Show key headers only | View raw


On Tuesday, March 26, 2013 11:07:45 AM UTC+1, Jean-Michel Pichavant wrote:
> ----- Original Message -----
> > 	notepad_1 = start("Notepad")
> > 	notepad_2 = start("Notepad")
> > 	notepad_1.write("Hello World!")
> > 	notepad_1.press(CTRL + 'a', CTRL + 'c')
> > 	notepad_2.press(CTRL + 'v')
> > 
> > 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. 
> 
> So is the example above. This is the best solution in my opinion. 

Thanks for your reply. What do you mean by "So is the example above" though? 

> I think you're having the same issue that some other APIs, let's say matplotlib for example. They try to accommodate scientists (matlab) and programmers(python) by having a double API style.
> 
> One looks like
> 
> legend()
> title()
> plot()
> save()
> 
> the other looks like
> 
> fig = figure()
> fig.add_legend()
> fig.title()
> fig.plot()
> fig.save()
> 
> 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 given to you in this thread and by the fact that with the correct (I)python shell, you can create your window object and get auto-completion on its methods just by hitting <tab>, very helpful when introspecting objects. Can be achieved of course in any python shell with function like dir() ; my point being that OOO design keeps things in their place, see the zen of python "Namespaces are one honking great idea -- let's do more of those!"

Doesn't the IPython do auto-completion for "global" functions? 

Thanks,
Michael (www.getautoma.com)

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Help me pick an API design (OO vs functional) Jean-Michel Pichavant <jeanmichel@sequans.com> - 2013-03-26 11:07 +0100
  Re: Help me pick an API design (OO vs functional) Michael Herrmann <michael.herrmann@getautoma.com> - 2013-03-26 04:52 -0700
    Re: Help me pick an API design (OO vs functional) Chris Angelico <rosuav@gmail.com> - 2013-03-26 22:57 +1100
      Re: Help me pick an API design (OO vs functional) Michael Herrmann <michael.herrmann@getautoma.com> - 2013-03-26 05:20 -0700
  Re: Help me pick an API design (OO vs functional) Michael Herrmann <michael.herrmann@getautoma.com> - 2013-03-26 04:52 -0700

csiph-web