Why the value read from properties file in python doesn't work
<p>I am brand new to Python. I have some python script which is accessed by other project to read some data from this python script.</p>

<p>Past:
If suppose I need to provide the version information for the other project from this python script, I was having a class variable which was hard coded and it was working fine till now.</p>

<p>Now:
I wanted to change the way of providing the version information so I choose to read the properties file instead of hard coding. I have added these line in my script</p>

<p>previously it was just this line</p>

<pre><code>class Myclass
    version = '1.2'
</code></pre>

<p>Now I changed it to</p>

<pre><code> class Myclass
    config = ConfigParser.RawConfigParser()
    config.read('version.properties')
    version = config.get('global', 'version')
    print version
</code></pre>

<p>my version.properties file looks like</p>

<pre><code>[global]
version= 1.2
</code></pre>

<p>when I run this python file to print the version, it is clearly printing in the console. But when this variable is being accessed by that other project the version read from the properties file is not being read (Hard coded value works just fine).</p>

<p>What could be the difference? Why is the value read from properties file is not reflecting?</p>

<p>If the <code>version.properties</code> file will be in the same directory as your code, you can use this:</p>

<pre><code>import os

config.read(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'version.properties'))
</code></pre>

python