Python: Printing value after .upper
<p>I am trying to print a string in all uppercase letters. When I run the print command it prints the type of x and the location. </p>

<p>Why does it print the operation instead of the result?</p>

<pre><code>x = 'bacon'
x = x.upper
print x

&gt;&gt;&gt; 
&lt;built-in method upper of str object at 0x02A95F60&gt;
</code></pre>

<p><code>upper</code> (and all other methods) is something like "function ready to use", that way you can do:</p>

<pre><code>x = 'bacon'
x = x.upper
print x()
</code></pre>

<p>But the most common to see, and the way I think you want is:</p>

<pre><code>x = 'bacon'
x = x.upper()
print x
</code></pre>

<p>"Ridiculous" example using <a href="http://www.secnetix.de/olli/Python/lambda_functions.hawk" rel="nofollow">lambda</a>:</p>

<pre><code>upper_case = lambda x: x.upper()
print(upper_case) # &lt;function &lt;lambda&gt; at 0x7f2558a21938&gt;
print(upper_case('bacon')) # BACON
</code></pre>

python python-2.7