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


Groups > comp.lang.python > #61564

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

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <marduk@letterboxes.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.024
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; '__name__': 0.09; 'received:internal': 0.09; 'subject:using': 0.09; 'whatever.': 0.09; 'implies': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'subject:python': 0.16; 'library': 0.18; "i've": 0.25; 'script': 0.25; 'post': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'usually': 0.31; 'received:66': 0.35; 'agree': 0.35; 'but': 0.35; 'add': 0.35; 'doing': 0.36; 'subject:?': 0.36; 'received:10': 0.37; 'stopped': 0.38; 'to:addr:python-list': 0.38; 'previous': 0.38; 'to:addr:python.org': 0.39; 'from:no real name:2**0': 0.61; 'header:Message-Id:1': 0.63; 'such': 0.63; 'more': 0.64; 'subject:there': 0.68; "'if": 0.84; 'clearer': 0.84
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=letterboxes.org; h=message-id:from:to:mime-version:content-transfer-encoding :content-type:in-reply-to:references:subject:date; s=mesmtp; bh= BiqWbI6WU/esUgq+f551ebUP5rY=; b=HARqNuZFU5fjyRqxBdI1apPJtUNYDX9T diedFS7Xp1D7o+Qwf4NNp7cKil+/PPVFmvpuVek3N188fh4Tfi2ZHg20FIR21bKM J5XKe3zmXpwPCMqz22nbVHDVGpAQiL5ed11KaBzJqI4Z0CzileRzYMkdGdID58Bn qsDYTEhGoSc=
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:from:to:mime-version :content-transfer-encoding:content-type:in-reply-to:references :subject:date; s=smtpout; bh=BiqWbI6WU/esUgq+f551ebUP5rY=; b=Slz k27WRReoHq5FWjIpoYC3jf/Qa4OrlYQTsgo2XyQtcv88no+2oX1+I/YPJaKeDmj7 0fZtZdOlNiHDoU5hSAqdKFR4pczKBU3E1SZS6FIx83hPtifr3gz0vNnlFa+g8AFq dW8WWU6NXL+YJFMgHVlFMPo/mGZ90+6QYQZoVp7A=
X-Sasl-Enc T7SbdkfOg36J1Wf3eMu340MIwUzy5G6fNsqZ3vyIyXzN 1386766652
From marduk@letterboxes.org
To python-list@python.org
MIME-Version 1.0
Content-Transfer-Encoding 7bit
Content-Type text/plain
X-Mailer MessagingEngine.com Webmail Interface - ajax-605a1389
In-Reply-To <7wsitzlm3o.fsf@benfinney.id.au>
References <32615c9a-b983-4399-bb55-6df6c230f247@googlegroups.com> <7wsitzlm3o.fsf@benfinney.id.au>
Subject Re: Is there any advantage to using a main() in python scripts?
Date Wed, 11 Dec 2013 07:57:32 -0500
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.3895.1386766655.18130.python-list@python.org> (permalink)
Lines 7
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1386766655 news.xs4all.nl 2907 [2001:888:2000:d::a6]:42658
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:61564

Show key headers only | View raw


I would agree with the previous post but also add that I've stopped
calling the main function "main()" and usually give it a more
descriptive name, such as "bake_cookies()" or whatever.  I think that
that makes it clearer what it's doing when used as a library and the 'if
__name__ == '__main__'" already implies that it is the "main" script
function.

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