importing a python dictionary only

hi

i’m trying to read a couple of blender addons and get some info from them, and i want to import the bl_info dictionary only, and i mean by only is i don’t want to import the imports in the script or any other class or method, i already searched the net and didn’t find a way i thought maybe here someone will help, is there a way to do that?

thank you.

Have you tried:


from <module> import <function/class/dictionary>

i.e.


from math import sin as my_sin
from math import pi as my_pi

print(my_sin(my_pi/2))

yes i did:

and it also imports the imports in the external py file!

i.e.

i have a file ‘script.py’ which contains:


bl_info = {
    "name": "something",
    "author": "someone",
    "version": (0, 0),
    "blender": (0,0,0)
    etc...
}


import bpy
import bpy
import urllib

class etc:
    do things

and i have the code to import that file:


from script import bl_info
print(bl_info['name'])

i’ll get an error on trying to import the bpy model!

one note that i don’t use blender as an ide, so normally bpy shouldn’t be available.

any thoughts.

trying to kick this thread, any tips guys, are there any python gurus here?

My only other suggestion would be to open the target .py file, extract the bl_info lines and use “eval” to load it yourself.

extract the bl_info lines and use “eval” to load it yourself.

thanks for the answer, i did but it gives error on loading the wiki or tracker url!, i also tried ast.literal_eval with the same result.