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


Groups > comp.lang.python > #61586

Re: Is there any advantage to using a main() in python scripts?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <bgailer@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.026
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'classes,': 0.05; 'importing': 0.05; 'subject:using': 0.09; 'modules,': 0.16; 'referencing': 0.16; 'stuff.': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'first,': 0.26; 'task': 0.26; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'am,': 0.29; 'actual': 0.34; 'classes': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'two': 0.37; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'to:addr:gmail.com': 0.65; 'subject:there': 0.68; 'add:': 0.84; 'me).': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=kivFLT2z6E2BOHa/IZz66h+a0lO1cgA2N1sJAiAeZ3o=; b=kbvEUCXNJMMVjH3I2eX2m9pyivG6k3Efj0NrG/ZRRiIqYFp5dicW/7ZdkbuwhmEKg0 7sGzjmBRfdUVwfuOPrrCeSC89uSCGkso1pd7S4dqGi2+wzK4QP8RpDOsApWn2dhp6xkI qgdzOuZGUTvweSyZ47Omlx1jTuXxMCq/7QfswV6JQwCxhnSMYFfdSh3V6eonwmPN5yiO Sl8JW6ji/e7csCd7RxCKAyav0U0yPDP7JxQakHen1/oN3mL/3jXJyMez3fvzjEv/fhxf HxmMAbdIdaMBm9UzKbYDlzOesLUA0W34Ri2eO44h0jVXY8UKaSa1rwWlmsWdUjAqLt+Z T+2w==
X-Received by 10.224.171.70 with SMTP id g6mr3827427qaz.80.1386776547992; Wed, 11 Dec 2013 07:42:27 -0800 (PST)
Date Wed, 11 Dec 2013 10:42:19 -0500
From bob gailer <bgailer@gmail.com>
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1
MIME-Version 1.0
To JL <lightaiyee@gmail.com>, python-list@python.org
Subject Re: Is there any advantage to using a main() in python scripts?
References <32615c9a-b983-4399-bb55-6df6c230f247@googlegroups.com>
In-Reply-To <32615c9a-b983-4399-bb55-6df6c230f247@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3904.1386776551.18130.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1386776551 news.xs4all.nl 2958 [2001:888:2000:d::a6]:54991
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:61586

Show key headers only | View raw


On 12/11/2013 4:55 AM, JL wrote:
> What is the advantage to using a main()?
In addition to what's been said I add:

It separates all the global activities: defining of functions and 
classes, importing modules, etc. from the "doing" the actual task of the 
program.

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.

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


Thread

Is there any advantage to using a main() in python scripts? JL <lightaiyee@gmail.com> - 2013-12-11 01:55 -0800
  Re: Is there any advantage to using a main() in python scripts? Ben Finney <ben+python@benfinney.id.au> - 2013-12-11 21:26 +1100
  Re: Is there any advantage to using a main() in python scripts? Chris Angelico <rosuav@gmail.com> - 2013-12-11 21:41 +1100
  Re: Is there any advantage to using a main() in python scripts? marduk@letterboxes.org - 2013-12-11 07:57 -0500
    Re: Is there any advantage to using a main() in python scripts? Roy Smith <roy@panix.com> - 2013-12-11 09:20 -0500
  Re: Is there any advantage to using a main() in python scripts? Roy Smith <roy@panix.com> - 2013-12-11 09:17 -0500
    Re: Is there any advantage to using a main() in python scripts? rusi <rustompmody@gmail.com> - 2013-12-11 06:24 -0800
  Re: Is there any advantage to using a main() in python scripts? bob gailer <bgailer@gmail.com> - 2013-12-11 10:42 -0500
  Re: Is there any advantage to using a main() in python scripts? Chris Angelico <rosuav@gmail.com> - 2013-12-12 02:49 +1100
  Re: Is there any advantage to using a main() in python scripts? Terry Reedy <tjreedy@udel.edu> - 2013-12-11 16:22 -0500

csiph-web