On 8/24/05, Andy Wardley <[EMAIL PROTECTED]> wrote: > Cees> You can fool TT into treating it like a list by using slice(0) > > Randal> Yow! I've been looking for an idiom for that. Thank you! > > That's a new one on me, too. Nice! > > BTW, the first argument defaults to 0 so you can simplify it to > [% obj.slice %].
So can we expect this behaviour to remain in the future? It could be considered an implementation side-effect! The reason it works it is because VMethods are looked at before TT checks the type of variable it is working on. I stumbled onto this because I had some objects that had a 'size' method that consistently failed to work correctly :) I would have expected TT to first try the call as a method before checking for a VMethod since it was dealing with an object (does it even make sense to call a VMethod on an object?). Since it does it the other way around, there is no way of calling a method on an object that has the same name as VMethod. Is there a good reason for this, or is it just the way things were implemented? Cheers, Cees _______________________________________________ templates mailing list [email protected] http://lists.template-toolkit.org/mailman/listinfo/templates
