* Syntax correction.

master
Wirawan Purwanto 9 years ago
parent 67f6e7bede
commit 6f91f61db4
  1. 7
      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):

Loading…
Cancel
Save