[Zope] DTML methods bafflement

Martijn Faassen M.Faassen@vet.uu.nl
Thu, 15 Apr 1999 20:51:35 +0200


Pavlos Christoforou wrote:
 
> Hi Martijn -

Hi Pavlos!

[snip my question]
 
> In python function arguments that have default values are evaluated at
> 'compilation' time.
> 
> So for example the following code raises an error:
> 
> def callee(a=b):
>         print b
> 
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
> NameError: b

Yes, but am I indeed using that part of Python? I was thinking I was
using (the equivalent of) this:

def callee(a, b, c): # (could also use default initializers here)
   print a, b, c

callee(a="foo", b="bar", c="baz")

And this works just fine in Python. this does too:

hey = "some text"
callee(a=hey, b="bar", c="baz")
 
> Seems that Zope will not raise an error when the DTML is originally
> defined, which is puzzling for me too.

I'm still not quite sure *why* it raises the error at all. If your
answer is the right one, I need some more explaining.. :)

Thanks, and regards,

Martijn