Feature request: String-inferred names

Cameron Simpson cs at zip.com.au
Thu Nov 26 20:16:53 EST 2009


On 25Nov2009 21:45, Brad <themusicguy123 at gmail.com> wrote:
| On Nov 25, 10:49 pm, Chris Rebert <c... at rebertia.com> wrote:
| > On Wed, Nov 25, 2009 at 6:35 PM, The Music Guy
| > <FearsomeDragon... at gmail.com> wrote:
| > > I just posted to my blog about a feature that I'd like to see added to
| > > Python. Before I go through the trouble of learning how to write a PEP or
| > > how to extend the Python interpreter, I want to know what people in the
| > > community have to say about it.
| > >http://alphaios.blogspot.com/2009/11/python-string-inferred-names-wor...
[...]
| > Ugly, Perlish, and as you even admit, entirely unnecessary.
| > And you'd need to wait at least a year anyway:http://www.python.org/dev/peps/pep-3003/
| 
| Like I said, lots of things in Python are "unnecessary," but that
| doesn't make them "useless," and it certainly doesn't mean they
| shouldn't exist. My proposed feature is not useless; I think it would
| make a lot of code easier.

The Zen promotes the guideline that there should be only one (obvious)
way to do most things and that's a surprisingly effective design rule.

For your idea the obvious ways already exist.

If you really want this you can achieve nearly the same conciseness by
defining __setitem__ and __getitem__ so that:

  obj[attrname] = foo

does what you want.
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

For reading rec.moto, I use one of those carbon-fiber Logitech mice w/a
little 'No Fear' sticker on it. - Mike Hardcore DoD#5010 <moike at netcom.com>
                                  Apologies to Primus



More information about the Python-list mailing list