Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Error using idlsave #988
Accessing s1['dn'] should work fine within IPython like in the regular Python shell.
Until this is fixed in IPy, the workaround is to use s1.get('dn')
As @takluyver reported on-list, we should catch any error here, and not assume that objects are well behaved.
I would consider it a bug in AttrDict that missing attributes raises anything other than AttributeError, because it breaks extremely basic Python functionality.
I'm not sure we should catch all errors here: objects that raise WhoKnowsWhatError on attribute access are simply broken objects, and I'm worried that having blanket exception clause here can mask other problems in the future. So I'm inclined to say we leave things as they are, and that this error simply serves as a good warning system for people of bugs in their code :)
From Python docs for
So hasattr itself checks for arbitrary errors, rather than just AttributeError.
In which case:
try: auto_rewrite = obj.rewrite except Exception: auto_rewrite = True
is identical to
if hasattr(obj, 'rewrite'): auto_rewrite = obj.rewrite else: auto_rewrite = True
Except the latter actually calls