How to rename texture with script?

Hi!

I try to rename “bpy.context.object.data.materials[0].texture_slots[0]” when it’s exist.

That’s will reporting “”"
Traceback (most recent call last):
File “<blender_console>”, line 1, in <module>
AttributeError: bpy_struct: attribute “name” from “MaterialTextureSlot” is read-only
“”"

texture_slots.add() need no arguments.
texture_slots.create() just need a index int… So

Still can’t give it a name!

Welcome any sugestion.

Thanks!

You could try


tex_name = bpy.context.object.data.materials[0].texture_slots[0].name
bpy.data.textures[tex_name].name = 'Texture'

Don’t really know why it’s read-only.