Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions run-python-scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# How to Run Your Python Scripts and Code

This folder provides the code examples for the Real Python tutorial [How to Run Your Python Scripts and Code](https://realpython.com/run-python-scripts/).
3 changes: 3 additions & 0 deletions run-python-scripts/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# hello.py

print("Hello, World!")
3 changes: 3 additions & 0 deletions run-python-scripts/hello_shebang.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env python3

print("Hello, World!")
2 changes: 2 additions & 0 deletions run-python-scripts/run_exec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
with open("hello.py") as hello:
exec(hello.read())
3 changes: 3 additions & 0 deletions run-python-scripts/run_importlib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import importlib

importlib.import_module("hello")
5 changes: 5 additions & 0 deletions run-python-scripts/run_reload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import importlib

import hello_shebang # First import. Second import does nothing

importlib.reload(hello_shebang)