Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7639 > unrolled thread
| Started by | MRAB <python@mrabarnett.plus.com> |
|---|---|
| First post | 2011-06-14 23:57 +0100 |
| Last post | 2011-06-14 23:57 +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.
Re: break in a module MRAB <python@mrabarnett.plus.com> - 2011-06-14 23:57 +0100
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2011-06-14 23:57 +0100 |
| Subject | Re: break in a module |
| Message-ID | <mailman.239.1308092256.11593.python-list@python.org> |
On 14/06/2011 23:28, Eric Snow wrote: [snip] > With modules I sometimes have code at the beginning to do some small > task if a certain condition is met, and otherwise execute the rest of > the module body. Here's my main use case: > > """some module""" > > import sys > import importlib > import util # some utility module somewhere... > > if __name__ == "__main__": > name = util.get_module_name(sys.modules[__name__]) > module = importlib.import_module(name) > sys.modules[__name__] = module > else: > # do my normal stuff at 1 indentation level > > I would rather have something like this: > > """some module""" > > import sys > import importlib > import util # some utility module somewhere... > > if __name__ == "__main__": > name = util.get_module_name(sys.modules[__name__]) > module = importlib.import_module(name) > sys.modules[__name__] = module > break > > # do my normal stuff at 0 indentation level > > So, any thoughts? Thanks. > To me, the obvious choice would be "return", not "break".
Back to top | Article view | comp.lang.python
csiph-web