diff --git a/IPython/core/magic.py b/IPython/core/magic.py index 4fc67be..cacd639 100644 --- a/IPython/core/magic.py +++ b/IPython/core/magic.py @@ -25,7 +25,6 @@ import shutil import re import time import textwrap -import types from cStringIO import StringIO from getopt import getopt,GetoptError from pprint import pformat @@ -57,7 +56,7 @@ import IPython.utils.io from IPython.utils.path import get_py_filename from IPython.utils.process import arg_split, abbrev_cwd from IPython.utils.terminal import set_term_title -from IPython.utils.text import LSString, SList, StringTypes, format_screen +from IPython.utils.text import LSString, SList, format_screen from IPython.utils.timing import clock, clock2 from IPython.utils.warn import warn, error from IPython.utils.ipstruct import Struct @@ -848,7 +847,7 @@ Currently the magic system has the following functions:\n""" - For {},[],(): their length. - - For numpy and Numeric arrays, a summary with shape, number of + - For numpy arrays, a summary with shape, number of elements, typecode and size in memory. - Everything else: a string representation, snipping their middle if @@ -881,7 +880,7 @@ Currently the magic system has the following functions:\n""" # if we have variables, move on... # for these types, show len() instead of data: - seq_types = [types.DictType,types.ListType,types.TupleType] + seq_types = ['dict', 'list', 'tuple'] # for numpy/Numeric arrays, display summary info try: @@ -940,7 +939,7 @@ Currently the magic system has the following functions:\n""" for vname,var,vtype in zip(varnames,varlist,typelist): print itpl(vformat), if vtype in seq_types: - print len(var) + print "n="+str(len(var)) elif vtype in [array_type,ndarray_type]: vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1] if vtype==ndarray_type: @@ -2307,7 +2306,7 @@ Currently the magic system has the following functions:\n""" #print '*** args',args,'type',type(args) # dbg data = eval(args,self.shell.user_ns) - if not type(data) in StringTypes: + if not isinstance(data, basestring): raise DataIsObject except (NameError,SyntaxError):