Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do we want a section on package structure in "expressive code?" #45

Open
sneakers-the-rat opened this issue Oct 22, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@sneakers-the-rat
Copy link
Contributor

Continuing a thought here: #44 (comment)

I like the lessons that are developing here a lot!

So in the section on expressive code there are a lot of good ideas about naming, and right near the end it seems like there is a really nice spot to do a super brief spot about expressiveness in package structure.

What i'm thinking is something like

  • in the same way that you group related operations into a function, you can think of a python module as a grouping of related functions, and a package is a nested grouping of modules.
    • you can use the structure of your package to communicate meaning as well
    • (i.e. the temperature.conversion.f_to_k/fahrenheit_to_kelvin example)
  • your package structure and names can help someone know how to use your package
    • _private variable names indicate when something is an implementation detail they shouldn't use
    • importing objects from modules into a namespace and using __all__ = [] is another way to signal which things are intended to be used, and a way for you to signal relative importance/commonness - eg. pandas imports all their user-facing functions to the top level so you can do stuff like pd.to_datetime instead of needing to do pandas.core.api.to_datetime or pandas.core.tools.datetimes.to_datetime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants