From 6f91f61db4067e10ef36fd001f4fec1a8c75d6c8 Mon Sep 17 00:00:00 2001 From: Wirawan Purwanto Date: Wed, 19 Aug 2015 17:48:42 -0400 Subject: [PATCH] * Syntax correction. --- py/introspection.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/py/introspection.py b/py/introspection.py index 810bd7f..28767f6 100644 --- a/py/introspection.py +++ b/py/introspection.py @@ -15,6 +15,9 @@ def name_rlookup(val, namespace, prefix=None, rx_match=None, lookup="dict"): This is useful for example to reverse-lookup an object's name, but only in restricted contexts (e.g. when the value to look for is unique). + + `prefix` or `rx_match` can be given to narrow the scope of names to look for. + The two cannot be given at once; `prefix` will take precedence in that case. """ # Imported 20150819 # Original subroutine name: search_var_name (from Cr2_analysis_cbs.py). @@ -23,9 +26,9 @@ def name_rlookup(val, namespace, prefix=None, rx_match=None, lookup="dict"): else: # attribute lookup names = dir(namespace) - if prefix != None: + if prefix is not None: names_filt = [ n for n in names if n.startswith(prefix) ] - elif rx_match != None: + elif rx_match is not None: # TODO later: for my regexp object? if True: if isinstance(rx_match, basestring):