def clone obj count clone obj count list of cloned objects Clone an ob

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
>>> def clone(obj, count=1):
... """
... clone(obj, count=1) -> list of cloned objects
...
... Clone an object a specified number of times, returning the cloned
... objects as a list. This is just a shallow copy only.
...
... obj
... Any Python object
... count
... Number of times the object will be cloned
...
... >>> clone(object(), 2)
... [<object object at 0x12345678>, <object object at 0x87654321>]
... """
... import copy
... return [copy.copy(obj) for x in count]
...
>>> print(inspect.getdoc(clone))
clone(obj, count=1) -> list of cloned objects
Clone an object a specified number of times, returning the cloned
objects as a list. This is just a shallow copy only.
obj
Any Python object
count
Number of times the object will be cloned
>>> clone(object(), 2)
[<object object at 0x12345678>, <object object at 0x87654321>]
>>>