Ros python packages __init__ level imports
I noticed that in native ROS packages all available modules seem to be imported at package level always. For example let us consider the rosbag
python package. This is the output I see when I print the list of modules imported at package-level.
>>> import rosbag
>>> dir(rosbag)
['Bag', 'Compression', 'ROSBagException', 'ROSBagFormatException', 'ROSBagUnindexedException', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'bag', 'migration', 'rosbag_main', 'rosbagmain']
However the __init__.py
file of rosbag package does not explicitly import bag
, migration
and rosbag_main
. How are these these modules getting imported by themselves?
In order to verify if this is something done by the catkin build system, I wrote my own ros python package. My custom package did't any modules imported at package level. So my question is what makes the ROS native python packages special to cause this behavior?
In order to understand this question better, if you want to access the rosbag source, see the link https://github.com/ros/ros_comm/tree/...