diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2019-05-23 11:28:24 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2019-05-23 11:29:49 +0300 |
commit | 8022bd705908a0e0bfd615a4e64d5140f326a8d1 (patch) | |
tree | 5c260556431acfca4fdccb86d70ad1c1033d015b /doc/python_api/examples/bpy.types.Depsgraph.5.py | |
parent | 58c4b10a708fbc24bca105dbf26dd991154c91ad (diff) |
Depsgraph examples: don't assign to names of built-in Python objects
`object` is the superclass of all objects. Old-style code could still be
using `class SomeClass(object)` and assigning something else to `object`
could have unexpected results.
This is now also documented in the
[Python style guide](https://wiki.blender.org/wiki/Style_Guide/Python)
on the wiki.
Differential Revision: https://developer.blender.org/D4922
Reviewed by: sergey
Diffstat (limited to 'doc/python_api/examples/bpy.types.Depsgraph.5.py')
-rw-r--r-- | doc/python_api/examples/bpy.types.Depsgraph.5.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/doc/python_api/examples/bpy.types.Depsgraph.5.py b/doc/python_api/examples/bpy.types.Depsgraph.5.py index 335e87071e5..0f578b37d47 100644 --- a/doc/python_api/examples/bpy.types.Depsgraph.5.py +++ b/doc/python_api/examples/bpy.types.Depsgraph.5.py @@ -30,16 +30,16 @@ class OBJECT_OT_mesh_from_object(bpy.types.Operator): def execute(self, context): # Access input original object. - object = context.object - if object is None: + obj = context.object + if obj is None: self.report({'INFO'}, "No active mesh object to convert to mesh") return {'CANCELLED'} # Avoid annoying None checks later on. - if object.type not in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META'}: + if obj.type not in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META'}: self.report({'INFO'}, "Object can not be converted to mesh") return {'CANCELLED'} depsgraph = context.evaluated_depsgraph_get() - object_eval = object.evaluated_get(depsgraph) + object_eval = obj.evaluated_get(depsgraph) mesh_from_eval = bpy.data.meshes.new_from_object(object_eval) self.report({'INFO'}, f"{len(mesh_from_eval.vertices)} in new mesh, and is ready for use!") return {'FINISHED'} |