How to import a variable from different file types
<p>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?</p>

<p>Thanks for any help</p>

<pre><code>import os

from version import VERSION_ID

def versionid:

    print VERSION_ID
</code></pre>

<p>This is the code that does not work.</p>

<p>The version ID is 0.0.2 format. When I run the below code it says there is a syntax error in the number.</p>

<p>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?</p>

<p>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</p>

<pre><code>VERSION_ID=map(int,re.match("VERSION_ID\s*=\s*(\S+)",open("version.mk").read()).group(1).split("."))
</code></pre>
