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


Groups > comp.lang.python > #4586 > unrolled thread

Re: vertical ordering of functions

Started byMRAB <python@mrabarnett.plus.com>
First post2011-05-03 23:46 +0100
Last post2011-05-03 23:46 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: vertical ordering of functions MRAB <python@mrabarnett.plus.com> - 2011-05-03 23:46 +0100

#4586 — Re: vertical ordering of functions

FromMRAB <python@mrabarnett.plus.com>
Date2011-05-03 23:46 +0100
SubjectRe: vertical ordering of functions
Message-ID<mailman.1132.1304462821.9059.python-list@python.org>
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.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web