##// END OF EJS Templates
Initial implementation of %pastebin magic command.
Initial implementation of %pastebin magic command.

File last commit:

r3406:66f66203
r3491:f1424652
Show More
macro.py
33 lines | 1.1 KiB | text/x-python | PythonLexer
"""Support for interactive macros in IPython"""
#*****************************************************************************
# Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu>
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#*****************************************************************************
import IPython.utils.io
class Macro(object):
"""Simple class to store the value of macros as strings.
Macro is just a callable that executes a string of IPython
input when called.
Args to macro are available in _margv list if you need them.
"""
def __init__(self,code):
"""store the macro value, as a single string which can be executed"""
self.value = code.rstrip()+'\n'
def __str__(self):
return self.value
def __repr__(self):
return 'IPython.macro.Macro(%s)' % repr(self.value)
def __getstate__(self):
""" needed for safe pickling via %store """
return {'value': self.value}