Allowing attribute and/or item access within templating expressions has historically been the domain of full-on templating languages (which invariably also have a way to do repeats, conditionals, arbitrary method calls, etc).
I think it should probably stay that way because to me, at least, there's not much more compelling about being able to do item/ attribute access within a template expression than there is to be able to do replacements using results from arbitrary method calls. It's fairly arbitrary to allow calls to __getitem__ and __getattr__ and but prevent, say, calls to "traverse", at least if the format arguments are not restricted to plain lists/tuples/dicts. That's not to say that maybe an extended templating thingy shouldn't ship within the stdlib though, maybe even one that extends the default interpolation syntax in these sorts of ways. - C On Jun 20, 2007, at 10:49 AM, Nick Coghlan wrote: > Chris McDonough wrote: >> Wrt http://www.python.org/dev/peps/pep-3101/ >> PEP 3101 says Py3K should allow item and attribute access syntax >> within string templating expressions but "to limit potential >> security issues", access to underscore prefixed names within >> attribute/item access expressions will be disallowed. > > Personally, I'd be fine with leaving at least the embedded > attribute access out of the initial implementation of the PEP. I'd > even be OK with leaving out the embedded item access, but if we > leave it in "vars(obj)" and the embedded item access would still > provide a shorthand notation for access to instance variable > attributes in a format string. > > So +1 for leaving out embedded attribute access from the initial > implementation of PEP 3101, and -0 for leaving out the embedded > item access. > > Cheers, > Nick. > > -- > Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia > --------------------------------------------------------------- > http://www.boredomandlaziness.org > _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
