Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use str.format in core magics.

  • Loading branch information...
commit 171d217e661f40b3e232212e5b4dade377ec9c1a 1 parent a121c33
@takluyver authored
Showing with 3 additions and 5 deletions.
  1. +3 −5 IPython/core/magic.py
View
8 IPython/core/magic.py
@@ -51,7 +51,6 @@
from IPython.core import page
from IPython.core.prefilter import ESC_MAGIC
from IPython.lib.pylabtools import mpl_runner
-from IPython.external.Itpl import itpl, printpl
from IPython.testing.skipdoctest import skip_doctest
from IPython.utils.io import file_read, nlprint
from IPython.utils.path import get_py_filename
@@ -915,8 +914,7 @@ def type_name(v):
datalabel = 'Data/Info'
colsep = 3
# variable format strings
- vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
- vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
+ vformat = "{0:<{varwidth}}{1:<{typewidth}}"
aformat = "%s: %s elems, type `%s`, %s bytes"
# find the size of the columns to format the output nicely
varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
@@ -928,7 +926,7 @@ def type_name(v):
kb = 1024
Mb = 1048576 # kb**2
for vname,var,vtype in zip(varnames,varlist,typelist):
- print itpl(vformat),
+ print vformat.format(vname, vtype, varwidth=varwidth, typewidth=typewidth),
if vtype in seq_types:
print "n="+str(len(var))
elif vtype in [array_type,ndarray_type]:
@@ -962,7 +960,7 @@ def type_name(v):
if len(vstr) < 50:
print vstr
else:
- printpl(vfmt_short)
+ print vstr[:25] + "<...>" + vstr[-25:]
def magic_reset(self, parameter_s=''):
"""Resets the namespace by removing all names defined by the user.
Please sign in to comment.
Something went wrong with that request. Please try again.