0

getmembers from inspect doesn't return all the members. I am using this on a locally installed package, example code:

from inspect import getmembers, ismodule
import xyz
getmembers(xyz, ismodule)  # []
help('xyz.abc')
getmembers(xyz, ismodule)  # [('abc', <module xyz.abc ...>)]
help('xyz.lmn')
getmembers(xyz, ismodule)  # [('abc', <module xyz.abc ...>), ('lmn', <module xyz.lmn ...>)]

Why is this happening? May be help is importing the module, but when I do a import * manually it doesn't work!

Example,

from inspect import getmembers, ismodule
from xyz import *
getmembers(xyz, ismodule)  # []

But yes when I do a from xyz import abc specifically then it works and returns abc module, but how can I get all of them without running individual imports?

Ani Menon
  • 27,209
  • 16
  • 105
  • 126

0 Answers0