[IPython-dev] (no subject)

Sjoerd de Vries sjdv1982 at gmail.com
Mon Jul 7 05:12:32 EDT 2014


On Mon, Jul 7, 2014 at 5:03 AM, Thomas Kluyver <takowl at gmail.com> wrote:

> On 6 July 2014 15:58, Sjoerd de Vries <sjdv1982 at gmail.com> wrote:
>
>> Thank you for your response, but I am a bit sad to hear this. Now that
>> the sh profile is deleted, is system-shell-replacement no longer within the
>> scope of IPython, ?
>>
>
> As Fernando indicated, that's never really been IPython's aim. Of course
> we like seeing what people build with IPython, but that use case isn't
> something we especially support.
>

Thank you for this clarification, it's all clear now.
I will keep my hacks to myself for now, and I will distribute it as an
extension once there are the necessary hooks in IPython.


>
>
>> In addition, the extension would manipulate
>> input_transformer_manager.logical_line_transforms, so that the standard
>> input transformers "escaped_commands" and  "assign_from_system"  will be
>> overruled. This is a bit rude, but it should work.
>>
>
> That's OK, the input transformation API is there to allow this kind of
> extension. This is, however, a 'consenting adults' klnd of API - it's
> entirely possible to break IPython syntax with this, so it's up to you to
> ensure that things work together.
>
>

OK, I will take care :-)


> However, it would still require the following modifications to the IPython
>> core:
>> - Support for evaluators, and the use of AliasEvaluator by %alias (to
>> allow delayed evaluation)
>>
> - A hook to change the %alias formatter class from DollarFormatter (to
>> allow customized variable substitution)
>> - A hook in FullEvalFormatter._vformat to be triggered on certain
>> "conversion" values (for converters)
>>
>
> I think the simplest approach to this is something we've been talking
> about for a while - we shouldn't call var_expand for all magic commands.
> The obvious answer to this would be to not do it for any magics, and have
> the magics that want it call it internally, but we've hesitated because we
> think var_expand makes sense for the majority of magics, and it seems
> awkward to make them all call it for the sake of a few that don't. An
> alternative would be to decorate magic function definitions in some way to
> indicate that var_expand *shouldn't* be called (and leave calling them as
> the default).
>
>
This would be great! Perhaps an @expand_variable decorator for
IPython.core.magic.Magics?
I hope that the var_expand policy for each magic will be stored somewhere,
to make it overridable by "consenting adults" ;-)


>
>> - A hook to change the %alias formatter class from DollarFormatter (to
>> allow customized variable substitution)
>> - A hook in FullEvalFormatter._vformat to be triggered on certain
>> "conversion" values (for converters)
>>
>
What about these hooks, would they be OK? I can make a new branch with just
this, it's a dozen lines or less.


>
>>  - Additional optional arguments to interactiveshell methods
>> "getoutput", "system_piped" and "system_raw" (for variable substitution and
>> stderr capture)
>>
>
> I think an argument for stderr capture makes sense. For controlling
> variable substitution, it might be easier to go down a level, to the
> (similarly named) functions which they call after doing var_expand.
>

Well, I can copy-paste "getoutput" and "system_piped"  into my own
extension and make the necessary changes there, if that's best.

cheers

Sjoerd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140707/7a6f5aca/attachment.html>


More information about the IPython-dev mailing list