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

Add function ispackage to stdlib inspect #125633

Open
Xiaokang2022 opened this issue Oct 17, 2024 · 1 comment
Open

Add function ispackage to stdlib inspect #125633

Xiaokang2022 opened this issue Oct 17, 2024 · 1 comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@Xiaokang2022
Copy link
Contributor

Xiaokang2022 commented Oct 17, 2024

Feature or enhancement

Proposal:

Currently, the built-in module inspect lacks a function to determine whether an object is a package or not. This is a small but useful feature.

According to the documentation, this feature should not be difficult to implement, and we should add it to the standard library:

  1. Definition of a package
  2. module.__package__
  3. module.__name__
  4. module.__spec__

I've tried to implement this feature and will make a PR later.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

@Xiaokang2022
Copy link
Contributor Author

Xiaokang2022 commented Oct 17, 2024

My idea for implementing this feature is:

flowchart LR
    1(obj)
    2{is module?}
    3{hasattr 
    __ path __?}
    4(pkg)

    1 --> 2 --Y--> 3 --Y--> 4
Loading

@Xiaokang2022 Xiaokang2022 changed the title Adding function ispackage to stdlib inspect Add function ispackage to stdlib inspect Oct 17, 2024
@picnixz picnixz added the stdlib Python modules in the Lib dir label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants