python 2.7 - Copy instance of class of package -


i work rosbag package provided ros.org. code looks like

import rosbag  bag_path = "/path/to/bag/file.bag" bag = rosbag.bag(bat_path) 

and want is, copy instance bag correctly, because want process data in 2 different threads.

unfortunatelly, class bag not provide proper function copy().

so, how copy instance of external class properly?

thank support.

the copy package can used create new , identical instances of custom classes.

import copy  class testclass:    def __init__(self, a, b, c):        self.a =        self.b = b        self.c = c  x = testclass(1, 2, 3) y = copy.copy(x) 

x , y have save variable properties, if change x.a, y.a not affected.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -