简体   繁体   中英

How do you know that module you are importing is function or class?

In Python, a module can have functions, classes or both in the same module. When I am importing module into another module, is there a way to determine if the module has just functions or classes or both?

The reason I ask this is because classes will have to instantiated as objects whereas functions don't. So everytime I import , I want to know what I dealing with without getting into opening the module esp. the external modules.

This may be what you are looking for: How to check whether a variable is a class or not?

Not really sure what your use case is, but you may also find a use for the built-in dir function .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM