[Python-au] help debugging cacheability.py
Anthony Baxter
anthony at interlink.com.au
Wed Jul 20 15:08:23 CEST 2005
On Wednesday 20 July 2005 22:32, Andrew McNamara wrote:
> def __getattr__(self, attr):
> if attr[0] == '_':
> raise AttributeError
> attr = lower(replace(attr, '_', '-'))
> return self.data[attr]
Better yet would be
def __getattr__(self, attr):
if attr.startswith('__') and attr.endswith('__'):
raise AttributeError(attr)
attr = lower(replace(attr, '_', '-'))
return self.data[attr]
> I haven't verified it, but I imagine Python 1.5's hasattr() caught any
> exception and treated it as a missing attribute, rather than selectively
> catching AttributeError (I seem to remember some discussion of this on
> python-dev in the mists of time).
Yep. This bug was a pain in the arse, and I'm glad it's dead.
--
Anthony Baxter <anthony at interlink.com.au>
It's never too late to have a happy childhood.
More information about the python-au
mailing list