[IPython-User] Advice on using a prefilter
Tue Aug 7 15:43:59 CDT 2012
Le 7 août 2012 à 22:35, Aaron Meurer a écrit :
> Yeah, I came to the same conclusion (see my previous message). The
> API really needs to give the user the whole cell. The line-by-line
> API should be deprecated (or removed; I don't know how you guys tend
> to handle such things). The same thing is easy enough to get from the
> cell with .split("\n") if you really want it (and the user should
> probably be discouraged from doing so anyway, because the chances that
> you will get things wrong with line continuations is pretty high).
> In the meanwhile, any recommendations on how I should proceed? I see
> myself with the following options:
> - Use the existing prefilter API, and live with the fact that
> multiline statements won't be changed.
> - Monkey-patch run_cell. It's obviously not clean (to say the least),
> but it should fulfill my needs completely.
> - Don't do anything; wait until you guys have a better API to work with.
If you can come up with a good API and a pull request which works and is merged
you'll have your solution :-)
> Any suggestions? Is monkey-patching run_cell going to be as evil as it sounds?
> Aaron Meurer
> On Tue, Aug 7, 2012 at 5:14 AM, Thomas Kluyver <email@example.com> wrote:
>> On 7 August 2012 05:47, Aaron Meurer <firstname.lastname@example.org> wrote:
>>>> Yes, that would be due to this bit of code:
>>> So can this if statement be removed?
>> Not trivially. The difficulty is that the context from previous lines
>> might affect whether something should be transformed - e.g. we mustn't
>> transform a line that's inside a string. And we need to be careful
>> about things like this:
>> In : 5 \
>> ...: % 2
>> Out: 1
>> Again, apologies that this API hasn't been better maintained.
>> Best wishes,
>> IPython-User mailing list
> IPython-User mailing list
More information about the IPython-User