On Apr 4, 2006, at 7:44 PM, Greg Ewing wrote: > I'm more interested in long-term readability > and maintainability than in pandering to one-off > impressions when coming from another language. > > I don't believe they would have any difficulty > "getting" this, anyway. Can you honestly say > that if you saw something like > > subst("User {user} has printed {n} pages", > user = user_code, n = page_count) > > you wouldn't instantly figure out what was > going on? > > There are other problems with the $ syntax too. > The lack of an explicit closing marker causes > problems when the parameter is immediately > followed in the string by an alphanumeric > character. You end up having to allow some > kind of bracketing as an optional extra > anyway, such as > > subst("I'm a ${what}spotter", what = "train") > > Seems to me it's simpler as well as clearer > to just make the syntax fully bracketed in the > first place. >
BTW, with string.Template's defaults, $what and ${what} are exactly equivalent. IOW, totally optional so if your substitution variable is followed by "non-identifier" characters, just use $what, otherwise use ${what}. I haven't tried, but string.Template might even support dropping the delimiter altogether, so that you could use just {what}. Give it a shot and let us know! :) -Barry _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com