4

Is it possible to write a python module (it will be used exclusively from ipython interpreter) and execute python magic functions?

E.g.

MyModule.ipy

def MyFunction(arg1, arg2, arg3):
    #do something useful
    %this_is_a_magic_function_call $arg1 $arg2 $arg3

MainModule.ipy

import MyModule

MyModule.MyFunction(1, 2, 3)

When I run ipython MainModule.ipy it ends with a "SyntaxError: invalid syntax". I suppose that the reason is that MyModule.ipy is not a valid python code, but haven't found if and how it is possible to use such modules.

Update: I have found this question (IPython Modules), where such practice is discouraged.

Community
  • 1
  • 1
Tadej Mali
  • 1,143
  • 8
  • 18

0 Answers0