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


Groups > comp.lang.python > #4589

Re: vertical ordering of functions

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; 'wed,': 0.04; 'statistical': 0.05; 'definitions': 0.07; 'whichever': 0.07; '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; 'term,': 0.09; 'underlying': 0.09; 'pm,': 0.11; '>>>': 0.12; 'am,': 0.14; 'wrote:': 0.14; 'defined': 0.15; 'bottom.': 0.16; 'definition,': 0.16; 'definition.': 0.16; 'enigma': 0.16; 'kern': 0.16; 'mrab': 0.16; 'namespace.': 0.16; 'received:216.62': 0.16; 'received:216.62.213': 0.16; 'received:enthought.com': 0.16; 'ties': 0.16; 'classes,': 0.19; 'functions,': 0.19; 'interpret': 0.19; 'header:In-Reply-To:1': 0.22; 'picking': 0.23; 'says': 0.25; 'define': 0.26; 'preferred': 0.26; "i'm": 0.26; 'chris': 0.27; 'function': 0.27; 'definition': 0.29; 'hi,': 0.29; 'effect': 0.29; 'class': 0.29; "won't": 0.30; 'does': 0.31; 'random': 0.31; 'called': 0.32; 'to:addr:python-list': 0.32; 'creates': 0.33; 'done,': 0.33; 'header:X-Complaints-To:1': 0.34; 'there': 0.35; 'header:User-Agent:1': 0.35; 'think': 0.36; 'should': 0.37; 'either': 0.37; 'issue': 0.37; 'consistent': 0.38; 'other,': 0.38; 'but': 0.38; 'third': 0.38; 'received:org': 0.38; 'though': 0.38; 'larger': 0.39; 'smaller': 0.39; 'to:addr:python.org': 0.39; 'header:Mime-Version:1': 0.39; 'how': 0.39; 'attempt': 0.40; 'level.': 0.40; 'would': 0.40; "it's": 0.40; 'header:Received:5': 0.40; 'evidence': 0.60; 'order': 0.61; 'further': 0.62; '2011': 0.62; 'our': 0.63; 'below': 0.63; 'entitled': 0.64; 'below.': 0.64; 'remember': 0.65; 'world': 0.65; 'believe': 0.66; 'flow': 0.69; 'average': 0.77; '(while': 0.84; 'best!': 0.84; 'clinical': 0.84; 'eco': 0.84; 'empirical': 0.84; 'hand.': 0.84; 'arrangement': 0.95
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Robert Kern <robert.kern@gmail.com>
Subject Re: vertical ordering of functions
Date Tue, 03 May 2011 19:17:49 -0500
Organization The Church of Last Thursday
References <BANLkTinuFqsVEroQH6Tm=Q1r8UGxZFBGpQ@mail.gmail.com> <BANLkTi==eNrKxq=wwewaV-iAdYgJ_sQBSg@mail.gmail.com> <4DC085E3.8000807@mrabarnett.plus.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host outbound.enthought.com
User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9
In-Reply-To <4DC085E3.8000807@mrabarnett.plus.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.1135.1304468285.9059.python-list@python.org> (permalink)
Lines 46
NNTP-Posting-Host 82.94.164.166
X-Trace 1304468285 news.xs4all.nl 81481 [::ffff:82.94.164.166]:40232
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:4589

Show key headers only | View raw


On 5/3/11 5:46 PM, MRAB wrote:
> On 03/05/2011 23:31, Chris Angelico wrote:
>> On Wed, May 4, 2011 at 8:08 AM, Jabba Laci<jabba.laci@gmail.com> wrote:
>>> Hi,
>>>
>>> I'm just reading Robert M. Martin's book entitled "Clean Code". In Ch.
>>> 5 he says that a function that is called should be below a function
>>> that does the calling. This creates a nice flow down from top to
>>> bottom.
>>
>> I prefer to define my terms before I use them. Classes, functions, etc
>> get defined at the top and called down below. It's a stylistic thing,
>> but it ties in with what you would do in a debate or scholarly
>> document; and if you're skimming such a document and you don't
>> understand a term, you know to scan upwards for its definition.
>>
>> It's just a stylistic thing, you can do it whichever way you think best!
>>
> You also need to remember that in Python, function and class
> definitions are _not_ declarations, but statements which have the
> effect of adding a name to the namespace.
>
> If you try to call a function before the flow of control has seen the
> function definition, you'll get a NameError.

That's not really the issue at hand. The advice is about how to order the 
definition of functions that call each other, not interspersing function calls 
at the top level.

I'm willing to bet that there is no solid empirical evidence that one ordering 
would be preferred to another. I am further willing to bet that should any such 
study be done, the average effect would be much smaller than personal variation 
(while it may be statistically significant, it won't be clinically significant). 
My third bet would be that picking any consistent style would have a larger 
effect over a random arrangement than either one consistent style over the 
other, and that this effect would be significant in both the statistical and 
clinical senses.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

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


Thread

Re: vertical ordering of functions Robert Kern <robert.kern@gmail.com> - 2011-05-03 19:17 -0500

csiph-web