Copying an Iris cube list? #5140
-
Hi, Is there a safe method to copy an Iris cube list, so that when I modify the new cube list it doesn't change the contents of the copied cube list? It appears that the copy() method is only for Iris cubes and not cube lists. Many thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
This was discussed in #3651, and it was decided that from copy import deepcopy
new_cube_list = deepcopy(my_cube_list) |
Beta Was this translation helpful? Give feedback.
-
That's great. Many thanks for your clear response. |
Beta Was this translation helpful? Give feedback.
This was discussed in #3651, and it was decided that
CubeList
should behave as close tolist
as possible. As such, if you want the members of the newCubeList
to be truly different from the originals, you need to usedeepcopy()
. See this Stack Overflow answer.