I am trying to obtain a variable from a different file type and import it into a Python script. The file is version.mk, it has a variable called VARIABLE_ID. The import module does not work as normally, is there any way to call variables from other file types?
Thanks for any help
import os
from version import VERSION_ID
def versionid:
print VERSION_ID
This is the code that does not work.
The version ID is 0.0.2 format. When I run the below code it says there is a syntax error in the number.
I have read that distutils has a version numbering convention. I am not sure how this could be used, has anyone heard or know how this works?
Is there a way of having cooments in this file, when comments are in the file it interferes with the file. Could the read() just read the version_id and not the comments, thanks
VERSION_ID=map(int,re.match("VERSION_ID\s*=\s*(\S+)",open("version.mk").read()).group(1).split("."))
If you are sure about
version.mkis valid python file, and does not have any harm codes, you can execute it.UPDATE: because OP Added VERSION_ID is not a valid python number
version.mk
–