From dd2f928c29b7cc9c6c47831b317a93dbc4d63943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 14 Oct 2021 14:56:22 +0200 Subject: [PATCH] Added Imports --- README.md | 11 +++++++++++ index.html | 13 +++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bbed66a..82b99f9 100644 --- a/README.md +++ b/README.md @@ -810,6 +810,17 @@ creature = Creature(point, direction) ``` +Imports +------- +```python +import # Imports a built-in or '.py'. +import # Imports a built-in or '/__init__.py'. +import . # Imports a built-in or '/.py'. +``` +* **Package is a collection of multiple modules, but it can also define its own objects. Python treats any directory containing a file called `'__init__.py'` as a package.** +* **Running `'import '` does not automatically provide access to package's modules unless they are imported in its init script.** + + Closure ------- **We have a closure in Python when:** diff --git a/index.html b/index.html index 14acf5f..a652a55 100644 --- a/index.html +++ b/index.html @@ -226,7 +226,7 @@ pre.prettyprint {
- +
@@ -841,6 +841,15 @@ direction = Direction.n Creature = make_dataclass('Creature', ['loc', 'dir']) creature = Creature(point, direction) +

#Imports

import <module>            # Imports a built-in or '<module>.py'.
+import <package>           # Imports a built-in or '<package>/__init__.py'.
+import <package>.<module>  # Imports a built-in or '<package>/<module>.py'.
+
+ +
    +
  • Package is a collection of multiple modules, but it can also define its own objects. Python treats any directory containing a file called '__init__.py' as a package.
  • +
  • Running 'import <package>' does not automatically provide access to package's modules unless they are imported in its init script.
  • +

#Closure

We have a closure in Python when:

  • A nested function references a value of its enclosing function and then
  • the enclosing function returns the nested function.
  • @@ -3007,7 +3016,7 @@ $ pyinstaller script.py --add-data '<path>:.'