A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-May/024157.html below:

[Python-Dev] PEP282 and the warnings framework

[Python-Dev] PEP282 and the warnings framework [Python-Dev] PEP282 and the warnings frameworkholger krekel pyth@devel.trillke.net
Thu, 16 May 2002 18:17:53 +0200
Barry A. Warsaw wrote:
> 
> >> If I have a choice between writing:
> >> 
> >>    log.debug(
> >>      "HOME environment variable set to non-existent directory %s",
> >>      homedir
> >>      )
> > 
> > with the mapping in my previous posting you would write
> > 
> >     log.debug(
> >         "HOME environment variable set to non-existent directory " + homedir
> >         )
> 
> >>>>> "A" == Aahz  <aahz@pythoncraft.com> writes:
> 
>     A> There is no difference between these two.
> 
> I'm coming in in the middle of this thread, but there is a very
> important difference between these two.

true. This citation is misleading. Originally this was
a question of convenience, not of 'what is better' really.

The better suggestion was, IMO, that for a growing application you
(might) prefer to write

    log.log(EnvMessage('HOME','non-existant directory'))

where EnvMessage will only acess os.environ if somebody
is interested in the Message (e.g. __str__ is called). 
This way you can systematically handle any problems with 
Environment variables and avoid typos etc...

    holger




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4