Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Issue 31 #292

Merged
merged 1 commit into from

3 participants

@takluyver
Owner

Issue #31 highlighted a couple of problems with the %whos command. I've fixed the info it gives on lists/dicts/tuples, and removed Numeric from the comments. For now, I've left the code in that handles Numeric arrays: I don't know if anyone actually still uses it, or if it's even possible to use it - I can't find a version of Numeric to download.

@takluyver
Owner

Turns out I actually have numeric installed from the repositories for some reason. It's still possible to use it, which means someone will, so the code to handle it may as well stay for now, but I don't think it needs a mention in the docstring. So this pull request should be OK for review.

@rkern

Looks good to me.

@fperez
Owner

merge away, thanks!

@takluyver takluyver merged commit a259897 into ipython:master
@damianavila damianavila referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 21, 2011
  1. @takluyver
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 6 deletions.
  1. +5 −6 IPython/core/magic.py
View
11 IPython/core/magic.py
@@ -25,7 +25,6 @@
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 @@
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 @@ def magic_whos(self, parameter_s=''):
- 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 @@ def magic_whos(self, parameter_s=''):
# 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 @@ def type_name(v):
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 @@ class DataIsObject(Exception): pass
#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):
Something went wrong with that request. Please try again.