copy object?

lallous lallous at
Tue Sep 1 16:04:21 CEST 2009


I am new to python and have some questions.

How to copy objects using another method than this:

    class op:
      def __init__(self, op):
        for x in dir(op):
          if x[:2] == "__":
          setattr(self, x, getattr(op, x))

o = op(src)

I tried to copy with "o = copy.copy(src)" but as soon as "src" is
gone, "o"'s attributes are not correct, and I cannot use copy.deepcopy
() because of this error:
TypeError: object.__new__(SwigPyObject) is not safe, use

Can the previous for loop be simplified and replaced with a map() and
a lambda function?


More information about the Python-list mailing list