Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!news2.arglkargh.de!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.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; 'else:': 0.03; 'subject:" ': 0.03; 'cpython': 0.05; 'flags': 0.05; 'guideline': 0.09; 'subject:Function': 0.09; 'wrote:': 0.15; '3.2.1': 0.16; 'subject: \n ': 0.16; 'subject:vs.': 0.16; 'thunderbird': 0.16; 'argument': 0.16; 'subject:was': 0.16; 'pm,': 0.16; 'this:': 0.16; 'def': 0.16; "wouldn't": 0.17; 'received:209.85.210.174': 0.19; 'received :mail-iy0-f174.google.com': 0.19; 'header:In-Reply-To:1': 0.22; 'code': 0.24; 'creating': 0.24; 'function': 0.26; 'windows': 0.26; 'mode': 0.28; 'id:': 0.29; 'annoying': 0.30; 'separated': 0.30; 'looks': 0.30; 'separate': 0.31; 'seem': 0.31; 'message- id:@gmail.com': 0.32; 'rather': 0.33; 'to:addr:python-list': 0.34; 'header:User-Agent:1': 0.34; "isn't": 0.35; 'functions.': 0.37; 'but': 0.37; 'received:192': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'strong': 0.38; 'steven': 0.38; 'think': 0.38; 'two': 0.38; 'received:192.168.1': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.40; 'easily': 0.61; 'subject:. ': 0.66; 'share': 0.68; 'attractive': 0.73; '5.0': 0.84; 'subject:!)': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=lNh/Eg8OYCrB/QBeQFgePkL0sRjfss67JmOayeCH7GE=; b=Xc0HMhtAIPyk/lWySxfxbzIShwOcA+TBBZUyFJbb8Glo2aXB5vX1D4jYvmrXCsQjJA d+hCDbuOEceglVECrf0oL1h3Iw5oMZg1S36fs0WjV4EmG2qR6Erqf3s0u2pnoY7z52zR lcXajhoF6QRP23y0+vCXkJrjcUWc1C00c3nbA= Date: Fri, 29 Jul 2011 20:15:35 -0500 From: Andrew Berg User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: "comp.lang.python" Subject: Function "modes" vs. separate functions (was: PyWart: os.path needs immediate attention!) References: <14874f59-a836-4031-a8c9-6b24f4d5e812@d7g2000vbv.googlegroups.com> <4e335535$0$29975$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: <4e335535$0$29975$c3e8da3$5496439d@news.astraweb.com> X-Enigmail-Version: 1.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1311988550 news.xs4all.nl 23958 [2001:888:2000:d::a6]:39794 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10562 On 2011.07.29 07:50 PM, Steven D'Aprano wrote: > Especially if the implementation looks like this: > > def get_thing(argument, flag): > if flag: > return one_thing(argument) > else: > return another_thing(argument) > Well, that would be annoying, but wouldn't it be even more annoying to do this: def get_one_thing(arg): return one_thing(arg) def get_another_thing(arg): return another_thing(arg) > Argument flags which do nothing but change the behaviour of the function > from Mode 1 to Mode 2 are an attractive nuisance: they seem like a good > idea, but aren't. Consider it a strong guideline rather than a law, but > it's one I would think very long and hard about before violating. Creating separate functions for two thing that do almost the same thing seem more of a nuisance to me, especially if they share a lot of code that isn't easily separated into other functions. -- CPython 3.2.1 | Windows NT 6.1.7601.17592 | Thunderbird 5.0 PGP/GPG Public Key ID: 0xF88E034060A78FCB