Answer the question
In order to leave comments, you need to log in
Why doesn't deepcopy work?
command = tools.get_attr_recursive(scripts, command_class_name)
# command.name по умолчанию пуст
# print(command.name)
# ""
self.commands[command_name] = copy.deepcopy(command)
self.commands[command_name].name = command_name
print(command.name, self.commands[command_name].name)
# command.name == self.commands[command_name].name
# True
Answer the question
In order to leave comments, you need to log in
short topic like this
import copy
class Command(object):
name = ""
cmd = Command
cmd2 = copy.deepcopy(Command)
assert cmd == cmd2
class Command(object):
name = ""
cmd = Command
cmd3 = type('NewCommand', Command.__bases__, dict(Command.__dict__))
assert cmd == cmd3 # AssertionError
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question