Python If Variable in Variable
<p>I Have Made A File Called <code>helloworld.simon</code>.
In There I  Have Written:</p>

<pre><code>Public class helloworld {
main = (main.method());
main {
    console.print("Hello World");
    }
</code></pre>

<p>And I Have Written This Code:</p>

<pre><code>Public = ("Public")
Private = ("Private")
code = open('helloworld.simon' , 'r')
print(code.read())
if Public in code:
    print("Pub")
else:
    print("J")
</code></pre>

<p>And The <em>Output</em> Is:</p>

<pre><code>Public class helloworld {
main = (main.method());
main {
    console.print("Hello World");
    }

J
</code></pre>

<p>File reading is sequential. Once you read a file (with <code>print(code.read())</code> you cant read back again, unless restart reading with <code>code.seek(0)</code></p>

<pre><code>Public = ("Public")
Private = ("Private")
code = open('helloworld.simon' , 'r')
print(code.read())
code.seek(0)
if Public in code.read():
    print("Pub")
else:
    print("J")
code.close()
</code></pre>

<p>outputs:</p>

<pre><code>Pub
</code></pre>

<p>If you comment <code>code.seek(0)</code>, outputs J</p>

python file filereader