Being an API reference, this link often gives little more information then the tool-tip, though some of the pages
include examples (normally at the top of the page).

At this point you may say Now what? - you know that you have to use .location and that its an array of 3 floats
but you’re still left wondering how to access this in a script.

So the next step is to find out where to access objects, go down to the bottom of the page to the References
section, for objects there are many references, but one of the most common places to access objects is via the context.

It’s easy to be overwhelmed at this point since there Object get referenced in so many places - modifiers,
functions, textures and constraints.

But if you want to access any data the user has selected
you typically only need to check the bpy.context references.

Even then, in this case there are quite a few though if you read over these - most are mode specific.
If you happen to be writing a tool that only runs in weight paint mode, then using weight_paint_object
would be appropriate.
However to access an item the user last selected, look for the active members,
Having access to a single active member the user selects is a convention in Blender: eg. active_bone,
active_pose_bone, active_node ... and in this case we can use - active_object.

So now we have enough information to find the location of the active object.

The previous example is quite straightforward because location is a property of Object which can be accessed
from the context directly.

Here are some more complex examples:

# access a render layers samplesbpy.context.scene.render.layers["RenderLayer"].samples# access to the current weight paint brush sizebpy.context.tool_settings.weight_paint.brush.size# check if the window is fullscreenbpy.context.window.screen.show_fullscreen

As you can see there are times when you want to access data which is nested
in a way that causes you to go through a few indirections.

The properties are arranged to match how data is stored internally (in blenders C code) which is often logical but
not always quite what you would expect from using Blender.

So this takes some time to learn, it helps you understand how data fits together in Blender which is important
to know when writing scripts.

When starting out scripting you will often run into the problem where you’re not sure how to access the data you want.

There are a few ways to do this.

Use the Python console’s auto-complete to inspect properties. This can be hit-and-miss but has the advantage
that you can easily see the values of properties and assign them to interactively see the results.

Copy the Data-Path from the user interface. Explained further in :ref:`Copy Data Path <info_data_path_copy>`

Using the documentation to follow references. Explained further in :ref:`Indirect Data Access <info_data_path_indirect>`

Blender can compute the Python string to a property which is shown in the tool-tip, on the line below Python:...,
This saves having to use the API reference to click back up the references to find where data is accessed from.

There is a user-interface feature to copy the data-path which gives the path from an bpy.types.ID data-block,
to its property.

To see how this works we’ll get the path to the Subdivision-Surface modifiers subdivision setting.

Start with the default scene and select the Modifiers tab, then add a Subdivision-Surface modifier to the cube.

Now hover your mouse over the button labeled View, The tool-tip includes bpy.types.SubsurfModifier.levels
but we want the path from the object to this property.

Note that the text copied won’t include the bpy.data.collection["name"]. component since its assumed that
you won’t be doing collection look-ups on every access and typically you’ll want to use the context rather
then access each bpy.types.ID instance by name.

Most key-strokes and buttons in Blender call an operator which is also exposed to python via bpy.ops,

To see the Python equivalent hover your mouse over the button and see the tool-tip,
eg Python:bpy.ops.render.render(),
If there is no tool-tip or the Python: line is missing then this button is not using an operator and
can’t be accessed from Python.

If you want to use this in a script you can press Control-C while your mouse is over the button to copy it to the
clipboard.

You can also right click on the button and view the Online Python Reference, this mainly shows arguments and
their defaults however operators written in Python show their file and line number which may be useful if you
are interested to check on the source code.

Note

Not all operators can be called usefully from Python, for more on this see using operators.