[Python-Dev] PEP282 and the warnings framework
holger 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