Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Clarify benefits of factory methods in Module 2

Open
#31 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
Half a day
Newbie friendliness
55/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Tech stack
jupyter-notebook, python
Domain
documentation

Research direction

Start with the static methods section in Module 2 and review its current explanation of factory methods. Add the requested terminology, rationale, and datetime and polars examples; done means the section explains when and why to use the pattern and includes the listed examples.

Written by the indexing model from the issue text.

Description

The static methods section in Module 2 shows how to create factory methods but could better explain when and why to use them.

Current state

The notes mention it's "less cumbersome" to create instances, but the pedagogical value could be stronger.

Suggested improvements

  1. Name the pattern - Use the term "factory method" or "alternative constructor" so students can recognize and search for it

  2. Explain the "why" - Python doesn't support multiple __init__ signatures, so factory methods provide multiple construction paths with semantic clarity

  3. Add stdlib examples from datetime:

    • datetime.fromtimestamp()
    • datetime.fromisoformat()
    • date.fromordinal()
  4. Add examples from polars:

    • pl.read_csv(), pl.read_parquet(), pl.read_json() (module-level factories)
    • DataFrame.to_dict()pl.from_dict() round-trip
    • pl.from_numpy(), pl.from_pandas()

These examples show the pattern is pervasive in well-designed Python APIs.

Dominant language
Jupyter Notebook
Stars
8
Forks
1
Avg merge
4m
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DHI/python-package-development

All issues in DHI/python-package-development

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.