##// END OF EJS Templates
Fixes and updates to %whos command.
Thomas Kluyver -
Show More
@@ -25,7 +25,6 b' import shutil'
25 import re
25 import re
26 import time
26 import time
27 import textwrap
27 import textwrap
28 import types
29 from cStringIO import StringIO
28 from cStringIO import StringIO
30 from getopt import getopt,GetoptError
29 from getopt import getopt,GetoptError
31 from pprint import pformat
30 from pprint import pformat
@@ -57,7 +56,7 b' import IPython.utils.io'
57 from IPython.utils.path import get_py_filename
56 from IPython.utils.path import get_py_filename
58 from IPython.utils.process import arg_split, abbrev_cwd
57 from IPython.utils.process import arg_split, abbrev_cwd
59 from IPython.utils.terminal import set_term_title
58 from IPython.utils.terminal import set_term_title
60 from IPython.utils.text import LSString, SList, StringTypes, format_screen
59 from IPython.utils.text import LSString, SList, format_screen
61 from IPython.utils.timing import clock, clock2
60 from IPython.utils.timing import clock, clock2
62 from IPython.utils.warn import warn, error
61 from IPython.utils.warn import warn, error
63 from IPython.utils.ipstruct import Struct
62 from IPython.utils.ipstruct import Struct
@@ -848,7 +847,7 b' Currently the magic system has the following functions:\\n"""'
848
847
849 - For {},[],(): their length.
848 - For {},[],(): their length.
850
849
851 - For numpy and Numeric arrays, a summary with shape, number of
850 - For numpy arrays, a summary with shape, number of
852 elements, typecode and size in memory.
851 elements, typecode and size in memory.
853
852
854 - Everything else: a string representation, snipping their middle if
853 - Everything else: a string representation, snipping their middle if
@@ -881,7 +880,7 b' Currently the magic system has the following functions:\\n"""'
881 # if we have variables, move on...
880 # if we have variables, move on...
882
881
883 # for these types, show len() instead of data:
882 # for these types, show len() instead of data:
884 seq_types = [types.DictType,types.ListType,types.TupleType]
883 seq_types = ['dict', 'list', 'tuple']
885
884
886 # for numpy/Numeric arrays, display summary info
885 # for numpy/Numeric arrays, display summary info
887 try:
886 try:
@@ -940,7 +939,7 b' Currently the magic system has the following functions:\\n"""'
940 for vname,var,vtype in zip(varnames,varlist,typelist):
939 for vname,var,vtype in zip(varnames,varlist,typelist):
941 print itpl(vformat),
940 print itpl(vformat),
942 if vtype in seq_types:
941 if vtype in seq_types:
943 print len(var)
942 print "n="+str(len(var))
944 elif vtype in [array_type,ndarray_type]:
943 elif vtype in [array_type,ndarray_type]:
945 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
944 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
946 if vtype==ndarray_type:
945 if vtype==ndarray_type:
@@ -2307,7 +2306,7 b' Currently the magic system has the following functions:\\n"""'
2307
2306
2308 #print '*** args',args,'type',type(args) # dbg
2307 #print '*** args',args,'type',type(args) # dbg
2309 data = eval(args,self.shell.user_ns)
2308 data = eval(args,self.shell.user_ns)
2310 if not type(data) in StringTypes:
2309 if not isinstance(data, basestring):
2311 raise DataIsObject
2310 raise DataIsObject
2312
2311
2313 except (NameError,SyntaxError):
2312 except (NameError,SyntaxError):
General Comments 0
You need to be logged in to leave comments. Login now