Permalink
Browse files

Renamed func to suffix (my own code confuses me) + minor amendments

  • Loading branch information...
1 parent 76bd1fa commit 797f323a7d0cef16faa22ba2de8811b3706483a1 @inky inky committed Sep 22, 2011
Showing with 14 additions and 9 deletions.
  1. +14 −9 see.py
View
23 see.py
@@ -76,6 +76,9 @@ def match(name, fn=fnmatch.fnmatch, pat=pat):
return tuple(filter(match, names))
+class SeeError(Exception): pass
+
+
class _SeeOutput(tuple):
"""Tuple-like object with a pretty string representation."""
@@ -131,20 +134,22 @@ def see(obj=_LOCALS, pattern=None, r=None):
in implements membership tests (e.g. x in obj)
+obj unary positive operator (e.g. +2)
-obj unary negative operator (e.g. -2)
+ ? raised an exception
"""
use_locals = obj is _LOCALS
actions = []
dot = not use_locals and '.' or ''
- name = lambda a, f: ''.join((dot, a, func(f)))
-
- def func(f):
- if f == SeeError: return '??'
- if hasattr(f, '__call__'): return '()'
- return ''
-
- class SeeError:pass
-
+ name = lambda a, f: ''.join((dot, a, suffix(f)))
+
+ def suffix(f):
+ if f == SeeError:
+ return '?'
+ elif hasattr(f, '__call__'):
+ return '()'
+ else:
+ return ''
+
if use_locals:
obj.__dict__ = inspect.currentframe().f_back.f_locals
attrs = dir(obj)

0 comments on commit 797f323

Please sign in to comment.