From 7f9a47211a6f848d22f6f9280d154135db3e0b60 Mon Sep 17 00:00:00 2001 From: Itay R <0xItx@users.noreply.github.com> Date: Sun, 19 Nov 2017 19:22:10 +0200 Subject: [PATCH] ptipython: set __file__ when running interactively Python code inspecting __file__ will find what it's looking for, rather than a ``NameError: name '__file__' is not defined`` --- ptpython/entry_points/run_ptipython.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ptpython/entry_points/run_ptipython.py b/ptpython/entry_points/run_ptipython.py index ac53a1f1..60d8e327 100644 --- a/ptpython/entry_points/run_ptipython.py +++ b/ptpython/entry_points/run_ptipython.py @@ -72,6 +72,7 @@ def run(user_ns=None): for path in startup_paths: if os.path.exists(path): with open(path, 'r') as f: + user_ns['__file__'] = path code = compile(f.read(), path, 'exec') six.exec_(code, user_ns, user_ns) else: