New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autocall fails if first function argument begins with "-" or "+ #81
Comments
[ LP comment 1 by: Fernando Perez, on 2010-04-25 01:48:04.569902+00:00 ] No, see this comment in the code:
Since any callable X could potentially also implement arithmetic, so that
is as valid as (and different from!):
We can't autocall on any binary operator. |
[ LP comment 2 by: Dirk Muders, on 2010-04-26 07:54:38.604015+00:00 ] I understand that argument. In our application we have created a user CLI based on IPython, partially because of being able to omit the parentheses. This makes it easier for users who are unfamiliar with Python but who have used other interfaces that do not need the parentheses. The case with signs (of course mostly the "-" sign) as first characters often occurs in our interface, hence the default IPython behavior breaks the general behavior of our interface and is thus undesirable. We are working with a locally modified version of IPython, but it would be nice to have an "official" switch to choose between the two options. |
[ LP comment 3 by: Fernando Perez, on 2010-04-26 19:21:31.005203+00:00 ] Well, if you are embedding IPython yourselves, you can try doing something like (this is code for trunk, the imports will be slightly different for 0.10):
Let me know if this works for you. If it does what you need OK, you have a workaround for now, and I'll then refactor the code to have an official API for this. I've reopened the bug so it stays tracked. |
[ LP comment 4 by: Dirk Muders, on 2010-04-27 07:23:54.060105+00:00 ] We are using IPython directly and we are currently working with a version that we edited in prefilter.py. Next time we upgrade IPython we would have to re-introduce this modification. For the time being we can work this way. |
[ LP comment 5 by: Fernando Perez, on 2010-04-27 18:08:52+00:00 ] OK. Since the upcoming 0.11 release is going to be somewhat of a Do ping us to remind us when the discussion on api requests comes up, Cheers, f |
@fperez, from reading the discussion, it seems like this is a 'working as intended' thing. Or do we want to keep it open as a feature request for optional disabling of autocall protection of binary operators? |
Sounds like this should just get closed, although I did whip up a proof-of-concept which makes the regular expression configurable. |
I'm not opposed to making that a configurable. Just the regexp pattern, which is simply a string, can be configurable by the users. If they pass a messed-up regexp that leads to non-sensical behavior, it's their own fault. I expect very few people would use this, but for some such as the OP, it could be a useful knob to tweak without having to monkeypatch us. |
Should I open a pull request for https://github.com/bfroehle/ipython/compare/_81_autocall_exclude_configurable ? |
This will be closed by #1713, in the sense that users are now able to configure this behavior. We won't change our defaults, but now it's a trivial user-facing change. |
…nfigurable Make autocall regexp's configurable. * Creates a new trait type "CRegExp" which casts a string or regular expression into a compiled regular expression. * Makes the autocall regular expressions, which are only used in AutocallChecker, configurable. Closes ipython#81.
Handling Exclude Flag in HTML, Markdown, and rST
…nfigurable Make autocall regexp's configurable. * Creates a new trait type "CRegExp" which casts a string or regular expression into a compiled regular expression. * Makes the autocall regular expressions, which are only used in AutocallChecker, configurable. Closes ipython#81.
Original Launchpad bug 315706: https://bugs.launchpad.net/ipython/+bug/315706
Reported by: dmuders (Dirk Muders).
Auto parentheses fail if the first argument of a function begins with "-" or "+". Thus these examples fail:
The reason is the re_exclude_auto in prefilter.py which reads
in v0.9.1. It appears that this line had been changed at some point after v0.6.2 to also catch operators. However, "-" and "+" can be used with numbers as shown above. Changing the line to
fixes the problem but I do not know if something else was intended by adding "+-". If so, then this would need to be caught in a different way.
The text was updated successfully, but these errors were encountered: