python different print output for <class 'str'> and <class 'str'>
<p>This is probably a basic question for most, yet it's not making sense to me.</p>

<p>When I try to print a str in the interpreter i'm getting different results back even though when I <code>type</code> them they are the same.</p>

<p>Here's the whole thing -></p>

<pre><code>&gt;&gt;&gt; print(abs.__doc__)
abs(number) -&gt; number

Return the absolute value of the argument.
&gt;&gt;&gt; type(abs.__doc__)
&lt;class 'str'&gt;

&gt;&gt;&gt; f_name = input('Enter a builtin: ')
Enter a builtin: abs
&gt;&gt;&gt; print(f_name + '.__doc__')
abs.__doc__
&gt;&gt;&gt; type(f_name + '.__doc__')
&lt;class 'str'&gt;
</code></pre>

<p>It would seem to me that they should return the same thing, the <code>pydoc</code> of <code>abs</code>.</p>

<p>Do I have to make a special call to make this work?</p>

<p>You're confusing a string, with an expression, <code>'abs.__doc__'</code> (string) is different from <code>abs.__doc__</code> (expression), you can evaluate the string as an expression with the <code>exec</code> function (Which you most probably shouldn't do unless you know what you're doing)</p>

python