Cannot access to addon preference value I have something like this in the my add-on __init__ file:

class MyPreferences(AddonPreferences):

    bl_idname = __name__

    num = IntProperty(name="Number", default=888)

    def draw(self, context):
        layout = self.layout
        layout.prop(self, "num")


I need to get this number from another file, and "MyPreferences.num" doesn't work. It returns a tuple, where the first value is "&lt;built-in function IntProperty&gt;" and the second value is a dictionary.

I can access the dictionary values, but the only ones available are "name", "attr", and "default", so if the user changes the property, I can't access the new value.

What should I do?
Something like this

addon = bpy.context.user_preferences.addons.get(addon_name)
if addon:
    prefs = addon.preferences
    print(prefs['num'])