##// END OF EJS Templates
Use str.format in core magics.
Thomas Kluyver -
Show More
@@ -51,7 +51,6 b' from IPython.core.macro import Macro'
51 51 from IPython.core import page
52 52 from IPython.core.prefilter import ESC_MAGIC
53 53 from IPython.lib.pylabtools import mpl_runner
54 from IPython.external.Itpl import itpl, printpl
55 54 from IPython.testing.skipdoctest import skip_doctest
56 55 from IPython.utils.io import file_read, nlprint
57 56 from IPython.utils.path import get_py_filename
@@ -915,8 +914,7 b' Currently the magic system has the following functions:\\n"""'
915 914 datalabel = 'Data/Info'
916 915 colsep = 3
917 916 # variable format strings
918 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
919 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
917 vformat = "{0:<{varwidth}}{1:<{typewidth}}"
920 918 aformat = "%s: %s elems, type `%s`, %s bytes"
921 919 # find the size of the columns to format the output nicely
922 920 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
@@ -928,7 +926,7 b' Currently the magic system has the following functions:\\n"""'
928 926 kb = 1024
929 927 Mb = 1048576 # kb**2
930 928 for vname,var,vtype in zip(varnames,varlist,typelist):
931 print itpl(vformat),
929 print vformat.format(vname, vtype, varwidth=varwidth, typewidth=typewidth),
932 930 if vtype in seq_types:
933 931 print "n="+str(len(var))
934 932 elif vtype in [array_type,ndarray_type]:
@@ -962,7 +960,7 b' Currently the magic system has the following functions:\\n"""'
962 960 if len(vstr) < 50:
963 961 print vstr
964 962 else:
965 printpl(vfmt_short)
963 print vstr[:25] + "<...>" + vstr[-25:]
966 964
967 965 def magic_reset(self, parameter_s=''):
968 966 """Resets the namespace by removing all names defined by the user.
General Comments 0
You need to be logged in to leave comments. Login now