for convenience

Chris Angelico rosuav at gmail.com
Mon Mar 21 17:17:32 EDT 2022


On Tue, 22 Mar 2022 at 08:13, Paul St George <email at paulstgeorge.com> wrote:
>
>
> When I am writing code, I often do things like this:
>
> context = bpy.context  # convenience
>
> then whenever I need bpy.context, I only need to write context
>
>
> Here’s my question:
>
> When I forget to use the convenient shorter form
>
> why is bpy.context not interpreted as bpy.bpy.context?
>

I don't understand the question. When you do that "for convenience"
assignment, what you're doing is creating a local variable named
"context" which refers to the same thing that bpy.context does (or did
at the time of the assignment, but presumably you only do this when
bpy.context won't get reassigned). It has no effect on any other name.
There's no magic happening here - it's just assignment to the name
context, like anything else.

What are you expecting to happen here?

ChrisA


More information about the Python-list mailing list