[Tutor] Why difference between printing string & typing its object reference at the prompt?
robertvstepp at gmail.com
Wed Oct 3 05:15:02 CEST 2012
After much diddling around I have finally settled on a text to study
(Programming in Python 3, 2nd edition, by Mark Summerfield) and have
defaulted to using IDLE, deferring worrying about editors/IDEs until I
feel comfortable in Python.
I am puzzled by the results of the following:
>>> x = "Test"
I understand that 'Test' is the stored value in memory where the
single quotes designate the value as being a string data type. So it
makes sense to me that just typing the object reference for the string
results in including the single quotes. But why does the print() strip
the quotes off? Is just as simple as normally people when performing a
print just want the unadorned text, so that is the behavior built into
the print function? Or is there something more subtle going on that I
am totally missing? If an explanation is in one of my several books,
it is currently eluding me.
More information about the Tutor