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


Groups > comp.lang.python > #10581

Re: PyWart: os.path needs immediate attention!

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'guido': 0.04; 'flags': 0.05; 'terry': 0.07; 'guideline': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'rule.': 0.09; 'api': 0.11; 'wrote:': 0.15; 'library': 0.15; '(usually,': 0.16; 'boolean': 0.16; 'params': 0.16; 'reedy': 0.16; 'always,': 0.16; 'argument': 0.16; 'pm,': 0.16; 'this:': 0.16; 'def': 0.16; 'say,': 0.19; 'jan': 0.19; 'seems': 0.20; 'header:In-Reply-To:1': 0.22; 'code': 0.24; 'function': 0.26; "i'm": 0.27; '(the': 0.28; 'mode': 0.28; 'constant': 0.29; 'situation,': 0.30; 'yet': 0.30; 'looks': 0.30; 'seem': 0.31; 'rather': 0.33; 'usually': 0.33; 'anyone': 0.33; 'to:addr:python-list': 0.34; 'header:X-Complaints- To:1': 0.34; 'header:User-Agent:1': 0.34; 'apply': 0.34; 'rule': 0.34; 'none': 0.35; 'that,': 0.35; 'pretty': 0.35; "isn't": 0.35; 'actual': 0.35; 'functions.': 0.37; 'but': 0.37; 'could': 0.37; 'another': 0.38; 'received:org': 0.38; 'takes': 0.38; 'subject:: ': 0.38; 'strong': 0.38; 'steven': 0.38; 'think': 0.38; 'two': 0.38; 'put': 0.38; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'basis': 0.62; 'subject:!': 0.67; 'attractive': 0.73; 'objective': 0.77; 'gut': 0.84; 'seldom': 0.84; 'shared,': 0.84; 'violate': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: PyWart: os.path needs immediate attention!
Date Sat, 30 Jul 2011 09:48:21 -0400
References <14874f59-a836-4031-a8c9-6b24f4d5e812@d7g2000vbv.googlegroups.com> <mailman.1623.1311961999.1164.python-list@python.org> <4e335535$0$29975$c3e8da3$5496439d@news.astraweb.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 206.205.249.126
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20110624 Thunderbird/5.0
In-Reply-To <4e335535$0$29975$c3e8da3$5496439d@news.astraweb.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1658.1312033703.1164.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1312033703 news.xs4all.nl 23950 [2001:888:2000:d::a6]:46622
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10581

Show key headers only | View raw


On 7/29/2011 8:50 PM, Steven D'Aprano wrote:

> Guido has a rule of thumb: "No constant arguments". Or another way to put
> it: if a function takes an argument which is nearly always a constant
> (usually, but not always, a flag) then it is usually better off as two
> functions.

I do not really understand his 'rule'*. The stdlib has lots of functions 
with boolean flags and params which default to None and are seldom 
over-ridden.

* Which is to say, it feels more like his gut feeling applied on a 
case-by-case basis than an actual rule that anyone could apply in any 
objective manner.

> Especially if the implementation looks like this:
>
> def get_thing(argument, flag):
>      if flag:
>          return one_thing(argument)
>      else:
>          return another_thing(argument)

If the rule is limited to this situation, where no code is shared, it 
seems pretty sensible.

> 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.
>
> But having said that, I'm currently writing a library where nearly all the
> functions violate the No Constant Argument rule. (The API isn't yet stable,
> so I may still change my mind.) Make of that what you will.

See * above ;-).

Terry Jan Reedy

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


Thread

PyWart: os.path needs immediate attention! rantingrick <rantingrick@gmail.com> - 2011-07-29 10:22 -0700
  Re: PyWart: os.path needs immediate attention! Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-29 12:53 -0500
    Re: PyWart: os.path needs immediate attention! harrismh777 <harmar@member.fsf.org> - 2011-07-29 14:41 -0500
      Re: PyWart: os.path needs immediate attention! "Waldek M." <wm@localhost.localdomain> - 2011-07-29 21:55 +0200
    Re: PyWart: os.path needs immediate attention! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-30 10:50 +1000
      Function "modes" vs. separate functions (was: PyWart: os.path needs immediate attention!) Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-29 20:15 -0500
        Re: Function "modes" vs. separate functions Ben Finney <ben+python@benfinney.id.au> - 2011-07-30 11:57 +1000
          Re: Function "modes" vs. separate functions Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-29 21:28 -0500
      Re: PyWart: os.path needs immediate attention! Terry Reedy <tjreedy@udel.edu> - 2011-07-30 09:48 -0400
      Re: PyWart: os.path needs immediate attention! Robert Kern <robert.kern@gmail.com> - 2011-07-30 23:31 -0400
  Re: PyWart: os.path needs immediate attention! Teemu Likonen <tlikonen@iki.fi> - 2011-07-29 23:07 +0300
    Re: PyWart: os.path needs immediate attention! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-30 10:57 +1000
      Re: PyWart: os.path needs immediate attention! Teemu Likonen <tlikonen@iki.fi> - 2011-08-01 11:19 +0300
        Re: PyWart: os.path needs immediate attention! rantingrick <rantingrick@gmail.com> - 2011-08-02 09:03 -0700
          Re: PyWart: os.path needs immediate attention! Chris Angelico <rosuav@gmail.com> - 2011-08-02 17:36 +0100
  Re: PyWart: os.path needs immediate attention! Chris Angelico <rosuav@gmail.com> - 2011-07-30 06:25 +1000
  Re: PyWart: os.path needs immediate attention! Corey Richardson <kb1pkl@aim.com> - 2011-07-29 16:44 -0400
  Re: PyWart: os.path needs immediate attention! Alister Ware <alister.ware@ntlworld.com> - 2011-07-29 21:21 +0000
    Re: PyWart: os.path needs immediate attention! Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-29 16:36 -0500
  Re: PyWart: os.path needs immediate attention! Chris Angelico <rosuav@gmail.com> - 2011-07-30 07:43 +1000
  Re: PyWart: os.path needs immediate attention! Terry Reedy <tjreedy@udel.edu> - 2011-07-29 19:30 -0400
  Re: PyWart: os.path needs immediate attention! Michael Poeltl <michael.poeltl@univie.ac.at> - 2011-07-30 02:30 +0200
    Re: PyWart: os.path needs immediate attention! Grant Edwards <invalid@invalid.invalid> - 2011-07-30 15:33 +0000
      Re: PyWart: os.path needs immediate attention! Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-30 10:56 -0500
        Re: PyWart: os.path needs immediate attention! alex23 <wuwei23@gmail.com> - 2011-08-02 23:52 -0700
  Re: PyWart: os.path needs immediate attention! Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-07-29 22:17 -0700
  Re: PyWart: os.path needs immediate attention! Gelonida N <gelonida@gmail.com> - 2011-08-03 11:52 +0200

csiph-web