From a14b1441d9ae9bc9a9a12e1c6ecc043a4462793c Mon Sep 17 00:00:00 2001 From: The Metaist Date: Thu, 12 Sep 2024 22:17:19 -0400 Subject: [PATCH] add: examples (#1) --- examples/pkg-nested/__init__.py | 0 examples/pkg-nested/sub-folder/__main__.py | 4 ++++ examples/pkg-with-init/__init__.py | 4 ++++ examples/pkg-with-main/__main__.py | 3 +++ examples/pkg-with-main/pkg.py | 5 +++++ examples/single-file/file-no-docstring.py | 2 ++ examples/single-file/file-no-main.py | 6 ++++++ examples/single-file/file-with-main.py | 5 +++++ 8 files changed, 29 insertions(+) create mode 100644 examples/pkg-nested/__init__.py create mode 100644 examples/pkg-nested/sub-folder/__main__.py create mode 100644 examples/pkg-with-init/__init__.py create mode 100644 examples/pkg-with-main/__main__.py create mode 100644 examples/pkg-with-main/pkg.py create mode 100644 examples/single-file/file-no-docstring.py create mode 100644 examples/single-file/file-no-main.py create mode 100644 examples/single-file/file-with-main.py diff --git a/examples/pkg-nested/__init__.py b/examples/pkg-nested/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/pkg-nested/sub-folder/__main__.py b/examples/pkg-nested/sub-folder/__main__.py new file mode 100644 index 0000000..b55403c --- /dev/null +++ b/examples/pkg-nested/sub-folder/__main__.py @@ -0,0 +1,4 @@ +"""Example: package with nested folder""" + +if "__main__" == __name__: + print(__doc__) diff --git a/examples/pkg-with-init/__init__.py b/examples/pkg-with-init/__init__.py new file mode 100644 index 0000000..c6fc428 --- /dev/null +++ b/examples/pkg-with-init/__init__.py @@ -0,0 +1,4 @@ +"""Example: package with __init__.py""" + +if __name__ == "__main__": + print(__doc__) diff --git a/examples/pkg-with-main/__main__.py b/examples/pkg-with-main/__main__.py new file mode 100644 index 0000000..2f7c3b7 --- /dev/null +++ b/examples/pkg-with-main/__main__.py @@ -0,0 +1,3 @@ +from .pkg import main + +main() diff --git a/examples/pkg-with-main/pkg.py b/examples/pkg-with-main/pkg.py new file mode 100644 index 0000000..d4bd42e --- /dev/null +++ b/examples/pkg-with-main/pkg.py @@ -0,0 +1,5 @@ +"""Example: package with __main__.py""" + + +def main() -> None: + print(__doc__) diff --git a/examples/single-file/file-no-docstring.py b/examples/single-file/file-no-docstring.py new file mode 100644 index 0000000..e7bc395 --- /dev/null +++ b/examples/single-file/file-no-docstring.py @@ -0,0 +1,2 @@ +if __name__ == "__main__": + print("Example: file without docstring") diff --git a/examples/single-file/file-no-main.py b/examples/single-file/file-no-main.py new file mode 100644 index 0000000..855af1e --- /dev/null +++ b/examples/single-file/file-no-main.py @@ -0,0 +1,6 @@ +"""Example: file without `__main__`""" + +# if __name__ == "__main__": +# print(__doc__) + +print(__doc__) diff --git a/examples/single-file/file-with-main.py b/examples/single-file/file-with-main.py new file mode 100644 index 0000000..e9c56a0 --- /dev/null +++ b/examples/single-file/file-with-main.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python +"""Example: file with `__main__`""" + +if __name__ == "__main__": + print(__doc__)