Minor bug in tempfile module (possibly __doc__ error)
Marc Christiansen
usenet at solar-empire.de
Thu May 10 04:59:02 EDT 2007
James T. Dennis <jadestar at idiom.com> scribis:
> In fact I realized, after reading through tempfile.py in /usr/lib/...
> that the following also doesn't "work" like I'd expect:
>
> # foo.py
> tst = "foo"
> def getTst(arg):
If I change this line:
> return "foo-%s" % arg
to:
return "%s-%s" % (tst, arg)
> # bar.py
> import foo
> foo.tst = "bar"
> print foo.getTst("testing")
>
> foo-testing <<<----- NOT "bar-testing"
Then "python bar.py" prints "bar-testing".
0:tolot at jupiter:/tmp> cat foo.py
tst = "foo"
def getTst(arg):
return "%s-%s" % (tst,arg)
0:tolot at jupiter:/tmp> cat bar.py
import foo
foo.tst = "bar"
print foo.getTst("testing")
0:tolot at jupiter:/tmp> python bar.py
bar-testing
And regarding the tempfile.template problem, this looks like a bug.
Because all functions in tempfile taking a prefix argument use "def
function(... , prefix=template, ...)", only the value of template at
import time matters.
Adiaŭ, Marc
More information about the Python-list
mailing list