durusmail: quixote-users: 'return' in templates
'return' in templates
2002-05-02
'return' in templates
Jonathan Corbet
2002-05-02
This is one I've encountered a couple of times, so I decided to dig in a
bit.  If I have a template function like:

        template t (...):

                if something_abnormal:
                    '''Explain abnormal stuff here'''
                    return

This kind of template gets the "...returned None" error out of Quixote.

Now, the PTL document says "Inside templates, you can use all of Python's
control-flow statements."  But this doesn't quite seem to be the case with
return.  It all works if I put in:

        return str (__output)

...but somehow that seems, um, inelegant.

So...is the real scoop that one simply should not use a no-value "return"
within templates, or am I missing something here?

Thanks,

jon

Jonathan Corbet
Executive editor, LWN.net
corbet@lwn.net



reply