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

Function read_pyfile

Lib/test/test_unparse.py:13–17  ·  view source on GitHub ↗

Read and return the contents of a Python source file (as a string), taking into account the file encoding.

(filename)

Source from the content-addressed store, hash-verified

11
12
13def read_pyfile(filename):
14 """Read and return the contents of a Python source file (as a
15 string), taking into account the file encoding."""
16 with tokenize.open(filename) as stream:
17 return stream.read()
18
19
20for_else = """\

Callers 1

test_filesMethod · 0.85

Calls 2

openMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…