Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.054 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'subject:using': 0.09; 'cc:addr:python-list': 0.11; 'language.': 0.14; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'locating': 0.16; 'referencing': 0.16; 'stuff.': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'thu,': 0.19; 'cc:addr:python.org': 0.22; '(or': 0.24; 'cc:2**0': 0.24; 'source': 0.25; 'first,': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'dec': 0.30; 'message- id:@mail.gmail.com': 0.30; 'classes': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'possible': 0.36; 'subject:?': 0.36; 'should': 0.36; 'two': 0.37; 'starting': 0.37; '12,': 0.39; 'even': 0.60; 'helps': 0.61; 'matter': 0.61; 'first': 0.61; 'subject:there': 0.68; 'me).': 0.84; 'recursion,': 0.84; 'to:none': 0.92; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=M5UdGKIhhsG1tO5SXm5tZUWIggEuWipqM6RjBbU4NWU=; b=IL/Z9Nq988i/fYPW93AQCV61UgMwifXkhxT1IAduKSy6AQNEsfHnWjSDwX8TdZAjEZ 3B8lUxIQ0KqnbXemralSn+aVgJL0dlrQCzLlZ76Sp4CqK/5d4vhqPRuzg4yATuHmLX38 0FHRndw/keyF2GLZwbLs52JxHqjwhOmcbxVpQfLqssWx1oFuOPuR2vvX1x3Alj9H0t/O 4uusCr8Ydv4vb9rphMvIQy87KYWxkVIpCmLi2uRx11tgTHLAiURwcyWHvp+POk7TkCcH vR53mSpiN/vKmAGjhP7XdPNle3bYpdMUJN86aBzqtIt56t3piDekL5zMPO9RXXDfJpY2 jj1g== MIME-Version: 1.0 X-Received: by 10.68.248.33 with SMTP id yj1mr2426936pbc.45.1386776964065; Wed, 11 Dec 2013 07:49:24 -0800 (PST) In-Reply-To: <52A887DB.6030600@gmail.com> References: <32615c9a-b983-4399-bb55-6df6c230f247@googlegroups.com> <52A887DB.6030600@gmail.com> Date: Thu, 12 Dec 2013 02:49:23 +1100 Subject: Re: Is there any advantage to using a main() in python scripts? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: , Newsgroups: comp.lang.python Message-ID: Lines: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1386776974 news.xs4all.nl 2901 [2001:888:2000:d::a6]:35997 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!porbandar.httrack.net!news.httrack.net!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:61588 On Thu, Dec 12, 2013 at 2:42 AM, bob gailer wrote: > It also ensures that the defining all the classes and functions happens > before referencing them (less "bookkeeping" for me). > > These two allow me to write the main program first, and follow it with all > the global stuff. I prefer define-before-use for readability, even if it doesn't matter to the language. It means that locating the source of something can be found by going upward (or starting at the top and going down - first hit should be the definition), and helps keep things organized. Obviously it's not always possible (mutual recursion, for instance), but it's a general rule of thumb that I like to maintain. ChrisA