Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 49

Ros python packages __init__ level imports

$
0
0
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 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 have the 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/lunar-devel/tools/rosbag/src/rosbag

Viewing all articles
Browse latest Browse all 49

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>