Ben North wrote: > Jack Jansen: > >> To me self.[method_name] = self.metadata.[method_name] looks better: >> what we're doing here is more like dictionary lookup than calling >> functions. >> > In the same way, though, would this be viewed as too similar to normal > dictionary/list indexing? > I think that's its strength; it's pleasantly symmetric to using [] on a dict:
dict attribute behavior -------------------------------- [] .[] pulls out named thing, throws exception on failure, no default, is an lvalue .get() .getattr() pulls out named thing, returns default value on error (specifiable as second argument), not an lvalue List comprehensions look like funny lists, generator expressions look like funny expressions, I see no reason why attribute dereferencing shouldn't look like funny dict dereferencing. +1. > What would the reaction be to > obj.{member} > instead? Braces are already used to construct dictionaries, so this has > some of the right connotations. -0.5. You're not constructing anything, you're looking up something. For the record, I'm also -1 on the two-argument form--this isn't a function call. /larry/ _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com