Defining a magic command

import string
import IPython.ipapi
def func( self, parameters= ”):
    params=parameters.split()
    print( "hello world", params)
ip = IPython.ipapi.get()
ip.expose_magic( 'mname', func)

These lines define the macro %mname. They could be part of ipy_user_conf.py.