{{ message }}
feat(curriculum): split Python modules lesson - #69838
Draft
majestic-owl448 wants to merge 4 commits into
Draft
Conversation
Contributor
Author
Dario-DC
reviewed
Sep 5, 2026
|
|
||
| But if the script is imported as a module, the code within that block doesn't run. | ||
|
|
||
| This is helpful because it allows Python scripts to have two purposes. They can be run directly to execute their main logic, or they can be imported into another module without executing their main logic. |
Contributor
Author
There was a problem hiding this comment.
tracked in PR description
|
|
||
| But how can you access the variables, constants, functions, and classes defined in these built-in modules? | ||
|
|
||
| You use an import statement. These statements let you import modules into your Python script. Import statements are generally written at the top of the file. Also, you can customize them based on your needs. First, you use the `import` statement, followed by the name of the module: |
Contributor
Author
There was a problem hiding this comment.
I have not changed this yet
Contributor
Author
There was a problem hiding this comment.
tracked in description
Co-authored-by: Dario <105294544+Dario-DC@users.noreply.github.com> Signed-off-by: majestic-owl448 <26656284+majestic-owl448@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Checklist:
mainbranch of freeCodeCamp.No issue.
This splits
What Is the Python Standard Library, and How Do You Import a Module?into three lessons in the existing Working with Modules block:How Do You Import Python Modules?keeps the import forms, aliases, qualified and direct imports, wildcard imports, namespace-collision guidance, and the two syntax questions.How Do You Create and Use Local Modules?receives the existingif __name__ == "__main__"material.How Do You Find and Use Standard-Library Modules?receives the standard-library definition, module examples,datetime.dateexample, documentation pointer, and standard-library definition question.This draft moves existing material only. The lesson scope and remaining work are tracked below:
How Do You Import Python Modules?
import moduleimport module as aliasfrom module import nameimport *is usually baddatetimemodule with an alias.meanfromstatisticsfor direct use.How Do You Create and Use Local Modules?
(but do we really want all this stuff? if we only keep
__name__ == '__main__'it goes back in the import lesson).pyfile with functions or constants.main.py.if __name__ == "__main__"here, where it makes sense.How Do You Find and Use Standard-Library Modules?
help()anddir().math,random,re, anddatetime.