Path: csiph.com!usenet.pasdenom.info!aioe.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'programmer': 0.03; 'advocate': 0.07; 'wednesday,': 0.07; 'option,': 0.09; 'subject:design': 0.09; 'sure,': 0.09; 'to:addr:comp.lang.python': 0.09; 'violates': 0.09; 'wrapper': 0.09; 'cc:addr:python-list': 0.11; 'subject:Help': 0.11; 'def': 0.12; "wouldn't": 0.14; 'parameter:': 0.16; 'subject:API': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'michael': 0.29; 'chris': 0.29; 'related': 0.29; "i'm": 0.30; 'code': 0.31; 'about.': 0.31; 'explained': 0.31; 'could': 0.34; 'subject: (': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'possible': 0.36; 'hi,': 0.36; 'url:amazon': 0.38; 'window': 0.38; 'handle': 0.38; 'resource': 0.38; 'march': 0.61; 'course': 0.61; 'such': 0.63; 'techniques': 0.66; 'clicking': 0.73; 'decorate': 0.84; '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=dmIjnPjTZh2hBCCD0mrQpxhxXWxGufWf0SVouK2fn5k=; b=oHRlaJCPGojsJAZTOsxYnKzh6iFf5JInTcepiu8TYkybiyrpRtIgSI3d6/daKC4MPt blSubWGiHuZe3/xx90wR1XQaoy28v9NrHeJpHddCAm3lAbyuwULV92R2PbELYx/H2MDJ sGa1n/VLQ45GprP571EHARm3+7nhzlyImLDYmahS+bgmC+o2ogXq1VkINUcnxIKsuX4m ip4UVibLx001JavFspvtiScGr6TCj3dGbEJYK8gtcfcQ7TNKL60oykkjQxzhvFUVc48q rgSK17z8s2mGg/oqEpBo9TgBST3e40JRc7F+brYdjXkwXoaVhsbxoFhNL6B1eDgmCqdB zg+w== X-Received: by 10.49.37.39 with SMTP id v7mr1336584qej.27.1364387037334; Wed, 27 Mar 2013 05:23:57 -0700 (PDT) Newsgroups: comp.lang.python Date: Wed, 27 Mar 2013 05:23:57 -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> <5b2ddb12-ad76-46f9-9f01-f67595b7ff54@googlegroups.com> <5483aad6-221e-46f8-8909-bf743e9fcb5c@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: ALoCoQnqAyWP7AGXJM0vJDuAFr4puWHRPYTu/WEZbK2/E+hUISMqR7j50O7H0qb2HFh3yQxK5cu1 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: , Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364387690 news.xs4all.nl 6873 [2001:888:2000:d::a6]:49681 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:42010 On Wednesday, March 27, 2013 12:44:49 PM UTC+1, Chris Angelico wrote: > ... > Not seeking to advocate this particular option, but it would be > possible to make a single wrapper for all your functions to handle the > focus=3D parameter: >=20 > def focusable(func): > @functools.wraps(func) > def wrapper(*args,focus=3DNone): > if focus: focus.activate() > return func(*args) > return wrapper >=20 > Then you just decorate all your functions with that: >=20 > def write(string): > # do something with the active window Hi, sure, I wouldn't have copy-pasted the code and of course there are tech= niques to avoid code duplication. It's not so much what I'm worried about. = What I'm worried about is that the concept of window-switching gets "smeare= d" over several other not-really related concepts such as clicking and typi= ng. I feel it violates orthogonality: http://www.artima.com/intv/dry3.html = is the best freely available resource I could find but I think it's best ex= plained in The Pragmatic Programmer http://www.amazon.com/Pragmatic-Program= mer-Journeyman-Master/dp/020161622X. Michael www.getautoma.com