Can Python "os.environ.get" ever return a non-string?
<p>In this code <a href="https://github.com/chimpler/pyhocon/blob/master/pyhocon/config_parser.py#L291" rel="nofollow">here</a>, they use <code>os.environ</code> to get the value of an environment variable, and then immediately check to see if it is an instance of their custom classes.</p>

<pre><code>value = os.environ.get(variable)
...
elif isinstance(value, ConfigList) or isinstance(value, ConfigTree):
</code></pre>

<p>Is it actually possible that the <code>value</code> will be an instance of their custom classes? Is this dead code?</p>

<p>The <code>os.environ</code> is just a simple mapping of <code>name: value</code>. It just adds some flavour on top of a dict to interact with the environment. Environment variables do not have type - their plain strings.</p>

<p>You can set variable types in bash, but this is not passed on to other programs.</p>

<pre><code>$ declare -xi FOO=2
$ python -c 'import os;print(type(os.environ["FOO"]))'
</code></pre>

<p>Even when you call a process from inside of python, you cannot pass other types than <code>str</code> or <code>bytes</code>.</p>

<pre><code>In [4]: subprocess.check_output(['python', '-c', 'import os;print(os.environ["FOO"])'], env={"FOO": 2})
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-4-94f33d136e8f&gt; in &lt;module&gt;()
----&gt; 1 subprocess.check_output(['python', '-c', 'import os;print(os.environ["FOO"])'], env={"FOO": 2})
</code></pre>

python environment-variables