diff options
author | Raymond Hettinger <python@rcn.com> | 2005-02-06 06:57:08 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2005-02-06 06:57:08 (GMT) |
commit | dbecd93b7203cd187c1978de1207c29d3a9a686c (patch) | |
tree | abb7331791de7b8e85208195e0c948a76cf77b67 /Lib/inspect.py | |
parent | 07ead1731850a9f1bd353b9330341309251099b6 (diff) | |
download | cpython-dbecd93b7203cd187c1978de1207c29d3a9a686c.zip cpython-dbecd93b7203cd187c1978de1207c29d3a9a686c.tar.gz cpython-dbecd93b7203cd187c1978de1207c29d3a9a686c.tar.bz2 |
Replace list of constants with tuples of constants.
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 05bb71b..03347b9 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -346,7 +346,7 @@ def getmodulename(path): def getsourcefile(object): """Return the Python source file an object was defined in, if it exists.""" filename = getfile(object) - if string.lower(filename[-4:]) in ['.pyc', '.pyo']: + if string.lower(filename[-4:]) in ('.pyc', '.pyo'): filename = filename[:-4] + '.py' for suffix, mode, kind in imp.get_suffixes(): if 'b' in mode and string.lower(filename[-len(suffix):]) == suffix: @@ -453,7 +453,7 @@ def getcomments(object): # Look for a comment block at the top of the file. start = 0 if lines and lines[0][:2] == '#!': start = 1 - while start < len(lines) and string.strip(lines[start]) in ['', '#']: + while start < len(lines) and string.strip(lines[start]) in ('', '#'): start = start + 1 if start < len(lines) and lines[start][:1] == '#': comments = [] @@ -621,7 +621,7 @@ def getargs(co): # The following acrobatics are for anonymous (tuple) arguments. for i in range(nargs): - if args[i][:1] in ['', '.']: + if args[i][:1] in ('', '.'): stack, remain, count = [], [], [] while step < len(code): op = ord(code[step]) @@ -630,7 +630,7 @@ def getargs(co): opname = dis.opname[op] value = ord(code[step]) + ord(code[step+1])*256 step = step + 2 - if opname in ['UNPACK_TUPLE', 'UNPACK_SEQUENCE']: + if opname in ('UNPACK_TUPLE', 'UNPACK_SEQUENCE'): remain.append(value) count.append(value) elif opname == 'STORE_FAST': @@ -696,7 +696,7 @@ def joinseq(seq): def strseq(object, convert, join=joinseq): """Recursively walk a sequence, stringifying each element.""" - if type(object) in [types.ListType, types.TupleType]: + if type(object) in (list, tuple): return join(map(lambda o, c=convert, j=join: strseq(o, c, j), object)) else: return convert(object) |