Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'argument': 0.05; 'explicit': 0.07; 'none,': 0.07; 'parameter': 0.09; 'subject:design': 0.09; 'window?': 0.09; 'wrapper': 0.09; 'subject:Help': 0.11; 'def': 0.12; 'enough.': 0.16; 'none.': 0.16; 'prefered': 0.16; 'received:74.208.4.195': 0.16; 'subject:API': 0.16; 'wrappers': 0.16; 'followed': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'normally': 0.19; 'meant': 0.20; 'header:User-Agent:1': 0.23; 'earlier': 0.24; '(or': 0.24; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'michael': 0.29; 'am,': 0.29; 'needed.': 0.30; 'allows': 0.31; 'figure': 0.32; 'subject: (': 0.35; 'something': 0.35; 'but': 0.35; 'add': 0.35; 'keyword': 0.36; "didn't": 0.36; 'should': 0.36; 'too': 0.37; 'clear': 0.37; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'future': 0.60; 'new': 0.61; 'march': 0.61; 'back': 0.62; 'provide': 0.64; 'sample': 0.67; '26,': 0.68; 'received:74.208': 0.68; 'default': 0.69; "they'd": 0.84; '2013': 0.98 Date: Tue, 26 Mar 2013 12:41:42 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Help me pick an API design (OO vs functional) References: <68da956e-ebe0-4f58-92cd-f7ffff0075b4@googlegroups.com> <5b2ddb12-ad76-46f9-9f01-f67595b7ff54@googlegroups.com> In-Reply-To: <5b2ddb12-ad76-46f9-9f01-f67595b7ff54@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:yF1/1myhxqds5I7B4Q3zCzVnoJSIooWJ3Bo/FTBUpqn SQvmyIjkA2/3PyuTAyLUEEVqti7dix54AtZ3vt9pOzqs/6yQTu vL3w/Y5AJk21p6Vv+aZFx33EyuHktGpX4R3tMTozX15bSUDAiB fuSBoa7unNHQBlRnSeuCqW3e99OKx/4cXoO09uETuheQq2XWXw XGDbWsViRV+EvkCx5UNxq4WNEsz4wCVRyoc2bVUhzJMezCmJJB B/xVcbQEQhg3IHorlyIs3xUALBgJeTz+YiPauvntGcHBSH6MtI djumX9EgMq1TyFSNb8FIi/ANac2XOifbxAqiq04xcHJB6EOfQ= = 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364316131 news.xs4all.nl 6852 [2001:888:2000:d::a6]:34832 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41921 On 03/26/2013 10:40 AM, Michael Herrmann wrote: > On Tuesday, March 26, 2013 3:13:30 PM UTC+1, Neil Cerutti wrote: >> >> >> Have you considered adding a keyword argument to each of your >> global functions, which is normally None, but allows a user to >> provide a prefered focus window? >> >> enter_text("test.txt", focus=save_dialog) >> >> press_button(Savebutton, focus=save_dialog) > > It's an interesting new idea but I somehow feel it makes the existing functions too complicated. Also, having to add it to all existing, and future functions sounds a bit too cumbersome to me. > Perhaps Neil didn't make it clear enough. I figure he meant a keyword argument with an explicit default value of None. (or if you followed my earlier discussion, default value of focused) That way your user can keep using the functions for when there's no ambiguity, but add a focus= parameter only when needed. To go back to my sample wrapper functions, they'd look something like (untested): def write(*args, focus=focused): focus.write(*args) Of course, the user should only use the wrappers when things are sure to remain "simple." -- DaveA