[Python-ideas] breaking out of module execution
mal at egenix.com
Wed Apr 25 11:41:35 CEST 2012
Nick Coghlan wrote:
> On Wed, Apr 25, 2012 at 10:55 AM, Steven D'Aprano <steve at pearwood.info> wrote:
>> In my opinion, this is an attractive nuisance.
>> -1 on the feature.
> Agreed (and my preferred idiom for all the cited cases is also "always
> define the Python version, override at the end with the accelerated
IMO, defining things twice in the same module is not a very Pythonic
way of designing Python software.
Left aside the resource leakage, it also makes if difficult to find
the implementation that actually gets used, bypasses "explicit is
better than implicit", and it doesn't address possible side-effects
of the definitions that you eventually override at the end of the
Python is normally written with a top-to-bottom view in mind, where
you don't expect things to suddenly change near the end.
This is why we introduced decorators before the function definition,
rather than place them after the function definition. It's also why
we tend to put imports, globals, helpers at the top of the file.
Professional Python Services directly from the Source (#1, Apr 25 2012)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
2012-04-28: PythonCamp 2012, Cologne, Germany 3 days to go
2012-04-25: Released eGenix mx Base 3.2.4 http://egenix.com/go27
::: Try our new mxODBC.Connect Python Database Interface for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
More information about the Python-ideas