"Compile time" checking?
Bengt Richter
bokr at oz.net
Wed Aug 10 22:35:40 EDT 2005
On Wed, 10 Aug 2005 20:39:03 +0100, zen19725 at zen.co.uk (phil hunt) wrote:
[...]
>
>I've not personally had problems with the wrong number of argumnets
>to a function call -- they get caught at run-time and are easy
>enough to fix -- but I do sometimes get errors because a varialbe is
>the wrong time, e.g. a string when it should be an int.
>
>One problem I once encountered was wit this and I waasn't picking it
>up because my debugging code looked like this:
>
> if debug: print "v=%s" % (v,)
>
>Which of course prints the same output whether v is '2' or 2.
>
>For this reason I tend to debug print statements like this now:
>
> if debug: print "v=%s" % (v,)
I usually prefer %r over %s for debug prints
if debug: print "v=%r" % (v,)
since it represents (repr's ;-) the v thing better
>>> print 'v=%r' % 2
v=2
>>> print 'v=%r' % '2'
v='2'
Regards,
Bengt Richter
More information about the Python-list
mailing list