diff --git a/Day 9 homework - Sloetjes.md b/Day 9 homework - Sloetjes.md index 315393b..507cc4a 100644 --- a/Day 9 homework - Sloetjes.md +++ b/Day 9 homework - Sloetjes.md @@ -73,3 +73,7 @@ print(login) * According to the Python language reference documentation on Importing Modules (section 5.6), the `__import__()` function is a low-level interface for dynamically importing modules at runtime. The documentation states that: > When the name variable is of the form package.module, normally, the top-level package (the name up till the first dot) is returned, not the module named by name. However, when a non-empty fromlist argument is given, the module named by name is returned. + +* In the code above, the name of the module is '"os"', and the fromlist argument is not given, so the top-level package '"os"' is returned, which is equivalent to importing os with a regular import statement. + +Therefore, the expression '__import__('os').getlogin()' is equivalent to 'os.getlogin()', but it dynamically imports the 'os' module at runtime instead of using a regular import statement.