[Python-ideas] Efficient debug logging
M.-A. Lemburg
mal at egenix.com
Thu Feb 16 09:20:51 EST 2017
On 16.02.2017 14:23, Victor Stinner wrote:
> 2017-02-16 13:55 GMT+01:00 M.-A. Lemburg <mal at egenix.com>:
>> 1. you don't need a preprocessor for this: simply put your
>> logging code into an "if __debug__:" block:
>
> The problem with -O is that it also disables assertions, whereas you
> may want to keep them at runtime on production for good reasons.
Assertions that you need in production should be written as
proper if-statements.
I know some people will disagree, but IMO using "assert" is the wrong
approach in such situations - it's meant for development and testing
only, not as short-cut to avoid having to write a proper error
handler :-)
If they were, Python would not drop creating code for them when
using Python in production -O mode.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Experts (#1, Feb 16 2017)
>>> Python Projects, Coaching and Consulting ... http://www.egenix.com/
>>> Python Database Interfaces ... http://products.egenix.com/
>>> Plone/Zope Database Interfaces ... http://zope.egenix.com/
________________________________________________________________________
::: We implement business ideas - efficiently in both time and costs :::
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
http://www.egenix.com/company/contact/
http://www.malemburg.com/
More information about the Python-ideas
mailing list