feat(curriculum): split Python modules lesson by majestic-owl448 · Pull Request #69838 · freeCodeCamp/freeCodeCamp · GitHub
Skip to content

feat(curriculum): split Python modules lesson - #69838

Draft
majestic-owl448 wants to merge 4 commits into
freeCodeCamp:mainfrom
majestic-owl448:feat/split-python-modules-lessons
Draft

feat(curriculum): split Python modules lesson#69838
majestic-owl448 wants to merge 4 commits into
freeCodeCamp:mainfrom
majestic-owl448:feat/split-python-modules-lessons

Conversation

@majestic-owl448

@majestic-owl448 majestic-owl448 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Checklist:

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 existing if __name__ == "__main__" material.
  • How Do You Find and Use Standard-Library Modules? receives the standard-library definition, module examples, datetime.date example, documentation pointer, and standard-library definition question.

This draft moves existing material only. The lesson scope and remaining work are tracked below:

  1. How Do You Import Python Modules?

    • import module
    • import module as alias
    • from module import name
    • Aliases for imported names
    • Qualified names, namespace collisions, and why import * is usually bad
    • Question 1 of 3: import the entire datetime module with an alias.
    • Question 2 of 3: import mean from statistics for direct use.
    • Question 3 of 3: write a question.
  2. 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)

    • Create a second .py file with functions or constants.
    • Import that file from main.py.
    • Show direct execution versus import.
    • Teach if __name__ == "__main__" here, where it makes sense.
    • Question 1 of 3: write a question.
    • Question 2 of 3: write a question.
    • Question 3 of 3: write a question.
  3. How Do You Find and Use Standard-Library Modules?

    • Standard library versus third-party packages.
    • Standard-library index, module pages, signatures, and examples.
    • help() and dir().
    • Brief discovery examples with math, random, re, and datetime.
    • Hand off module-specific behavior to dedicated lessons.
    • Question 1 of 3: identify the Python Standard Library.
    • Question 2 of 3: write a question about API discovery.
    • Question 3 of 3: write a question about API discovery.

@github-actions github-actions Bot added the scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. label Sep 2, 2026
@majestic-owl448

Copy link
Copy Markdown
Contributor Author


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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No questions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Odd start

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not changed this yet

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs another question

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants