MCPcopy Index your code
hub / github.com/python/cpython / main

Function main

Lib/symtable.py:420–447  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

418
419
420def main(args):
421 import sys
422 def print_symbols(table, level=0):
423 indent = ' ' * level
424 nested = "nested " if table.is_nested() else ""
425 if table.get_type() == 'module':
426 what = f'from file {table._filename!r}'
427 else:
428 what = f'{table.get_name()!r}'
429 print(f'{indent}symbol table for {nested}{table.get_type()} {what}:')
430 for ident in table.get_identifiers():
431 symbol = table.lookup(ident)
432 flags = ', '.join(symbol._flags_str()).lower()
433 print(f' {indent}{symbol._scope_str().lower()} symbol {symbol.get_name()!r}: {flags}')
434 print()
435
436 for table2 in table.get_children():
437 print_symbols(table2, level + 1)
438
439 for filename in args or ['-']:
440 if filename == '-':
441 src = sys.stdin.read()
442 filename = '<stdin>'
443 else:
444 with open(filename, 'rb') as f:
445 src = f.read()
446 mod = symtable(src, filename, 'exec')
447 print_symbols(mod)
448
449
450if __name__ == "__main__":

Callers 1

symtable.pyFile · 0.70

Calls 4

symtableFunction · 0.85
print_symbolsFunction · 0.85
openFunction · 0.70
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…