[IPython-dev] Auto-calling question

Dan Milstein danmil at comcast.net
Mon Feb 26 16:13:09 EST 2007


Just to follow up: when I say "nothing else from the core IPython  
system happens", I just mean the prefiltering stuff -- expanding  
aliases, interpreting %magic, etc.

-D

On Feb 26, 2007, at 4:08 PM, Dan Milstein wrote:

> I understand the CommandChainDispatcher idea, but it looks like the
> hooks get called in iplib._prefilter (l. 2081), like so:
>
>     rewritten = self.hooks.input_prefilter(stripped)
>     if rewritten != stripped: # ok, some prefilter did something
>         rewritten = pre + rewritten  # add indentation
>         return self.handle_normal(rewritten)
>     # Rest of _prefilter() continues here -- checking for %magic,
> alias, etc
>
> So that all hook-installed prefilters will play well together, but
> that, if any of those do anything, then self.handle_normal is called
> and nothing else from the core IPython system happens.  Is there
> something I'm missing?
>
> -D
>
> On Feb 26, 2007, at 3:38 PM, Ville M. Vainio wrote:
>
>> On 2/26/07, Dan Milstein <danmil at comcast.net> wrote:
>>
>>> Actually, since you bring that up, I have a question about
>>> input_prefilter:
>>>
>>> As far as I can tell from the code, if you install an  
>>> input_prefilter
>>> hook, then, for each line:
>>>
>>>   If your hook changes the line at all, then IPython does no more
>>> transformations (no magic, no autocall, etc)
>>>
>>>   If your hook runs but does *not* change the line, then IPython
>>> *does* run it's usual transformations
>>>
>>>
>>> a) Is that right?
>>
>> No, ipapi.TryNext takes optional args that modify what the next hook
>> gets as an arg.
>>
>> See ipapi.TryNext and hooks.CommandChainDispatcher (all the normal
>> hooks end up in CommandChainDispatcher "chains").
>>
>> Let us know if this is still unclear, with the current lack of  
>> example
>> use. And thank you for taking initiative in this!
>>
>> -- 
>> Ville M. Vainio - vivainio.googlepages.com
>> blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://lists.ipython.scipy.org/mailman/listinfo/ipython-dev




More information about the IPython-dev mailing list