On Jun 24, 1:20 am, Eduardo Dobay <[EMAIL PROTECTED]> wrote: > Hey, > > I think you could use lambda functions for that matter (Ever heard of > them?). You could write something like: > > def generate_html_tag_function(tag_name, start_or_end): > start_or_end.lower() > assert(start_or_end in ('start', 'end')) > if start_or_end == 'start': > function = lambda: '<' + tag_name + '>' > else: > function = lambda: '</' + tag_name + '>' > return function > > Then you would create the functions using the same code you had > written before: > > start_html = generate_html_tag_function('html', 'start') > start_body = generate_html_tag_function('body', 'start') > end_html = generate_html_tag_function('html', 'end') > end_body = generate_html_tag_function('body', 'end') > > That seems to do what you want. > > Eduardo
Thanks to all the repliers. @Eduardo: Yep, I had heard of lambdas, but didn't think to use them here. Will try this out - thanks! - Vasudev -- http://mail.python.org/mailman/listinfo/python-list