[Tutor] xls file
Kent Johnson
kent37 at tds.net
Wed Aug 22 13:31:19 CEST 2007
Kirk Bailey wrote:
> I extracted cell 0,0 and it is
> >>> x
> u'Bob Dobbs'
> >>>
>
> So I did this:
> >>> str(x)
> 'Bob Dobbs'
> >>>
> >>> b[1:-1]
> 'ob Dobb'
> >>>
> oops... well,then i did this
> >>> print b
> Bob Dobbs
> >>>
> which is as I need it. any use to the rest of the list?
You have discovered that the read-eval-print loop of the interpreter
prints repr(obj). repr() is kind of a programmer's view of something; it
often gives a representation of an object that you could use as input to
the interpreter. Specifically, for strings, repr(someString) includes
the quotes that you see printed in the interpreter. You will also
sometimes see backslash escapes like '\xe9' in the repr() of a string.
On the other hand, when you explicitly print a string, the characters of
the string are output directly to the terminal (stdout). Any special
characters are interpreted by the terminal rather that being escaped,
and the quotes are not added.
This is useful behaviour but it can be very confusing to newcomers.
Kent
PS Please use Reply All to reply to the list.
More information about the Tutor
mailing list