UserSpace.rename#
- UserSpace.rename(name)[source]#
Rename this space to a new name.
Changes the name of this
UserSpaceto the specifiedname.All cell values (both input and calculated) in the space are cleared recursively and all
ItemSpaceinstances in the space are deleted recursivelyRestrictions:
Cannot rename if the space is inherited by a recursive parent
New name must be a valid Python identifier
New name must not conflict with existing names in the parent
- Parameters:
name (str) – The new name for this space. Must be a valid Python identifier and unique within the parent.
- Raises:
ValueError – If the name is invalid or would create a conflict
Example
>>> space = model.new_space('OldName') >>> space.new_cells('foo', lambda x: x * 2) >>> space.foo(5) 10 >>> space.rename('NewName') >>> model.NewName.foo(5) # Values were cleared 10
Warning
This operation clears all values and deletes all ItemSpaces. Use with caution on spaces with significant computed data.
See also
copy(): Create a copy with a different name
Added in version 0.16.0.