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
Post a Comment