[IPython-dev] Should we disable autocall by default from now on?
Wed Nov 30 15:02:19 CST 2011
On Wed, Nov 30, 2011 at 11:51, Mark Voorhies <email@example.com> wrote:
> On Wednesday, November 30, 2011 10:00:54 am Thomas Kluyver wrote:
> > I maintain that altering state on attribute access, while it's perfectly
> > possible, is almost always a bad idea, for pretty much this reason: you
> > do very useful things by assuming that you're free to inspect attributes.
> I tend to agree with you. On the other hand, it's legal in the language,
> there is no C++-like concept of a const method to block this sort of side
> (meaning that people will do this sort of thing both deliberately and
Python is a language of unenforced convention, which allows for this kind
of magic vs magic conflict.
IPython's expectation that hasattr is safe is a reasonable one, as is
Traits' expectation that getattr
will only be called when the attribute is actually requested.
But Traits' behavior invalidates hasattr, and IPython's behavior can
trigger unrequested events.
It would be nice if there was a corresponding `__hasattr__`, so that
checking for attribute existence
could bypass side effects in objects that do getattr magic that should only
be triggered on *real* getattr.
Given that lack of autocall fails loudly and multiple attribute access
> fails silently,
> I think that setting the default to "fail loudly" (no autocall) makes
This makes perfect sense, and is a good general rule for such decisions.
I do think it will be newcomers using IPython to learn Python who will be
most adversely affected by the change, because a SyntaxError
is not helpful, while correcting the user is instructive.
> IPython-dev mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev