On Sun, 24 Apr 2005, Nick Coghlan wrote: [...] > Seeing this example has convinced me of something. PEP 310 should use the > 'with' > keyword, and 'expression block' syntax should be used to denote the 'default > object' semantics proposed for Python 3K. For example: > > class Key2AttributeError(object): > def __init__(self, obj, attr): > self: > .obj_type = type(obj) > .attr = attr > def __except__(self, ex_type, ex_val, ex_tb): > if isinstance(ex_type, KeyError): > self: > raise AttributeError("%s instance has no attribute %s" > % (.obj_type, .attr)) > > > # Somewhere else. . . > def __getattr__(self, name): > with Key2AttributeError(self, key): > self: > return ._cache[key] [...]
+1 Purely based on my aesthetic reaction, that is. Never having used other languages with this 'attribute lookup shorthand' feature, that seems to align *much* more with what I expect than the other way around. If 'with' is used in other languages as the keyword for attribute lookup shorthand, though, perhaps it will confuse other people, or at least make them frown :-( John _______________________________________________ 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