user: Show practical ways to work with Preferences(bpy_struct) in a Blender add-on or script – include code.

assistant: # Preferences(bpy_struct)

base class — [`bpy_struct`](bpy.types.bpy_struct.html#bpy.types.bpy_struct "bpy.types.bpy_struct")

*class* bpy.types.Preferences(*bpy_struct*)
:   Global preferences

    active_section
    :   Preferences

        Type:
        :   enum in [Preference Section Items](bpy_types_enum_items/preference_section_items.html#rna-enum-preference-section-items), default `'INTERFACE'`

    addons
    :   Type:
        :   [`Addons`](bpy.types.Addons.html#bpy.types.Addons "bpy.types.Addons") [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`Addon`](bpy.types.Addon.html#bpy.types.Addon "bpy.types.Addon"), (readonly)

    app_template
    :   Type:
        :   string, default “”, (never None)

    apps
    :   Preferences that work only for apps

        Type:
        :   [`PreferencesApps`](bpy.types.PreferencesApps.html#bpy.types.PreferencesApps "bpy.types.PreferencesApps"), (readonly, never None)

    autoexec_paths
    :   Type:
        :   [`PathCompareCollection`](bpy.types.PathCompareCollection.html#bpy.types.PathCompareCollection "bpy.types.PathCompareCollection") [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`PathCompare`](bpy.types.PathCompare.html#bpy.types.PathCompare "bpy.types.PathCompare"), (readonly)

    edit
    :   Settings for interacting with Blender data

        Type:
        :   [`PreferencesEdit`](bpy.types.PreferencesEdit.html#bpy.types.PreferencesEdit "bpy.types.PreferencesEdit"), (readonly, never None)

    experimental
    :   Settings for features that are still early in their development stage

        Type:
        :   [`PreferencesExperimental`](bpy.types.PreferencesExperimental.html#bpy.types.PreferencesExperimental "bpy.types.PreferencesExperimental"), (readonly, never None)

    extensions
    :   Settings for extensions

        Type:
        :   [`PreferencesExtensions`](bpy.types.PreferencesExtensions.html#bpy.types.PreferencesExtensions "bpy.types.PreferencesExtensions"), (readonly, never None)

    filepaths
    :   Default paths for external files

        Type:
        :   [`PreferencesFilePaths`](bpy.types.PreferencesFilePaths.html#bpy.types.PreferencesFilePaths "bpy.types.PreferencesFilePaths"), (readonly, never None)

    inputs
    :   Settings for input devices

        Type:
        :   [`PreferencesInput`](bpy.types.PreferencesInput.html#bpy.types.PreferencesInput "bpy.types.PreferencesInput"), (readonly, never None)

    is_dirty
    :   Preferences have changed

        Type:
        :   boolean, default False

    keymap
    :   Shortcut setup for keyboards and other input devices

        Type:
        :   [`PreferencesKeymap`](bpy.types.PreferencesKeymap.html#bpy.types.PreferencesKeymap "bpy.types.PreferencesKeymap"), (readonly, never None)

    studio_lights
    :   Type:
        :   [`StudioLights`](bpy.types.StudioLights.html#bpy.types.StudioLights "bpy.types.StudioLights") [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`StudioLight`](bpy.types.StudioLight.html#bpy.types.StudioLight "bpy.types.StudioLight"), (readonly)

    system
    :   Graphics driver and operating system settings

        Type:
        :   [`PreferencesSystem`](bpy.types.PreferencesSystem.html#bpy.types.PreferencesSystem "bpy.types.PreferencesSystem"), (readonly, never None)

    themes
    :   Type:
        :   [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`Theme`](bpy.types.Theme.html#bpy.types.Theme "bpy.types.Theme"), (readonly)

    ui_styles
    :   Type:
        :   [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`ThemeStyle`](bpy.types.ThemeStyle.html#bpy.types.ThemeStyle "bpy.types.ThemeStyle"), (readonly)

    use_preferences_save
    :   Save preferences on exit when modified (unless factory settings have been loaded)

        Type:
        :   boolean, default True

    use_recent_searches
    :   Sort the recently searched items at the top

        Type:
        :   boolean, default True

    version
    :   Version of Blender the userpref.blend was saved with

        Type:
        :   int array of 3 items in [0, inf], default (0, 0, 0), (readonly)

    view
    :   Preferences related to viewing data

        Type:
        :   [`PreferencesView`](bpy.types.PreferencesView.html#bpy.types.PreferencesView "bpy.types.PreferencesView"), (readonly, never None)

    *classmethod* bl_rna_get_subclass(*id*, *default=None*, */*)
    :   Parameters:
        :   **id** (*str*) – The RNA type identifier.

        Returns:
        :   The RNA type or default when not found.

        Return type:
        :   [`bpy.types.Struct`](bpy.types.Struct.html#bpy.types.Struct "bpy.types.Struct") subclass

    *classmethod* bl_rna_get_subclass_py(*id*, *default=None*, */*)
    :   Parameters:
        :   **id** (*str*) – The RNA type identifier.

        Returns:
        :   The class or default when not found.

        Return type:
        :   type