Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #90494
| Path | csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <davea@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'argument': 0.05; 'subject:Python': 0.06; 'assign': 0.07; 'needed,': 0.07; 'subject:file': 0.07; 'variables': 0.07; '"if': 0.09; 'clause': 0.09; 'global,': 0.09; 'logic': 0.09; 'parsing': 0.09; 'python': 0.11; '"global"': 0.16; "chris'": 0.16; 'clause.': 0.16; 'constants.': 0.16; 'subsequently': 0.16; 'top-level': 0.16; 'uppercase': 0.16; 'variables,': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'header:User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'statement': 0.30; 'code': 0.31; 'anyone': 0.31; 'file': 0.32; 'could': 0.34; "can't": 0.35; 'advice': 0.35; 'agree': 0.35; 'anywhere': 0.35; 'something': 0.35; 'but': 0.35; 'consistent': 0.36; 'thanks': 0.36; 'changing': 0.37; 'example,': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'anything': 0.39; 'does': 0.39; '12,': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'you.': 0.62; 'email addr:gmail.com': 0.63; 'such': 0.63; 'more': 0.64; 'charset:windows-1252': 0.65; 'side': 0.67; 'received:74.208': 0.68; 'export': 0.74; 'hand': 0.80; '2015': 0.84; 'batchelder': 0.84; "it'd": 0.84; 'approach.': 0.91 |
| Date | Tue, 12 May 2015 16:43:23 -0400 |
| From | Dave Angel <davea@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Python file structure |
| References | <f25aa9d4-4025-457d-8072-5327c98db1bd@googlegroups.com> <026e6357-917c-4d50-b70f-70903aa0e065@googlegroups.com> <05daad5f-b728-48ee-bf06-5e7374df936d@googlegroups.com> |
| In-Reply-To | <05daad5f-b728-48ee-bf06-5e7374df936d@googlegroups.com> |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V03:K0:9MkW+b80/2tgp0U1Cg/7fQr9qxuSaJc9VhMhWAlwuaF/SRynCwC ytmnsZDGgiLcUczIGKl8k5uNT+/vZ5waLnFF4U0xO+ociXG4ho5AtsteYClZZhCGsCiN2Cq zK4FEDI0ERMT4iylPRDxPOjaDxChwXqfIxmWfQJKXbpM8pMUDeYcSR+W1oZaj9lZZ+qsPYw aOB07ro4xIIwOSkcMn9qA== |
| X-UI-Out-Filterresults | notjunk:1; |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| 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.418.1431463424.12865.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1431463424 news.xs4all.nl 2899 [2001:888:2000:d::a6]:59270 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:90494 |
Show key headers only | View raw
On 05/12/2015 03:58 PM, zljubisicmob@gmail.com wrote: > On Tuesday, May 12, 2015 at 9:49:20 PM UTC+2, Ned Batchelder wrote: >> >> If you need to use globals, assign them inside a parse_arguments >> function that has a "global" statement in it. >> >> This advice is consistent with Chris' "define things before they >> are used." It does it by defining everything before anything is >> run. >> >> As a side note, if you are going to have code at the top-level of >> the file, then there's no point in the "if __name__..." clause. >> That clause is designed to make a file both runnable and importable. >> But your top-level code makes the file very difficult to import. >> >> --Ned. > > It makes sense. The only drawback is that variables are global only "if you need to use globals". You can't have it both ways. If they're needed, it's because you feel they must be changeable elsewhere in the program. I try to avoid global variables, but make no such restraints on the use of global constants. So for example, the argument parsing logic could very well export something as global, but it'd be all uppercase and anyone changing it subsequently would get their hand slapped by the linter. > so they could be changed anywhere in the program. > I also agree that it is more python approach. > > Thanks to both of you. > -- DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python file structure zljubisicmob@gmail.com - 2015-05-12 12:13 -0700
Re: Python file structure Chris Angelico <rosuav@gmail.com> - 2015-05-13 05:29 +1000
Re: Python file structure Ned Batchelder <ned@nedbatchelder.com> - 2015-05-12 12:49 -0700
Re: Python file structure zljubisicmob@gmail.com - 2015-05-12 12:58 -0700
Re: Python file structure Dave Angel <davea@davea.name> - 2015-05-12 16:43 -0400
Re: Python file structure Chris Angelico <rosuav@gmail.com> - 2015-05-13 06:02 +1000
Re: Python file structure Terry Reedy <tjreedy@udel.edu> - 2015-05-12 17:34 -0400
Re: Python file structure Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-12 13:54 -0600
Re: Python file structure Chris Angelico <rosuav@gmail.com> - 2015-05-13 06:07 +1000
Re: Python file structure Tim Chase <python.list@tim.thechases.com> - 2015-05-13 13:34 -0500
Re: Python file structure Chris Angelico <rosuav@gmail.com> - 2015-05-14 12:03 +1000
csiph-web