Templating and syntactic sugar

Tom Robinson tom at alkali.spamfree.org
Mon Aug 6 13:12:43 EDT 2001


On Mon, 6 Aug 2001 10:05:17 -0500, Skip Montanaro <skip at pobox.com>
wrote:

>
>    Tom> You can get and set variables in the template with tpl.var(), but I
>    Tom> want to be able to do something like tpl.var.xyzzy = "Hello,
>    Tom> world!", just because I like that syntax, but still have this
>    Tom> actually make a method call.  I'm pretty sure this is possible in
>    Tom> python (with operator overloading?), can anyone tell me how?
>
>Check up on __getattr__ and __setattr__.

Thanks, I've got it going now, seems to be working fine.  I ran into
problems with infinite loops at first but that seems to be a gotcha -
http://www.csse.monash.edu.au/~jon/python/gotcha/getattr.html was
helpful.

-- 
tom at alkali.spamfree.org
remove 'spamfree.' to respond



More information about the Python-list mailing list