python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout,

Rick Johnson rantingrickjohnson at
Sun Jul 6 18:53:34 CEST 2014

On Sunday, July 6, 2014 11:14:26 AM UTC-5, Terry Reedy wrote:
> On 7/6/2014 10:52 AM, Rick Johnson wrote:
> > So the direct reason for failure is due to the fact that the
> > "print()" function ONLY handles strings, not list objects.
> >>> print(object())
> <object object at 0x00000000020D2140>  
> >>> print(['abc', 'cdf'])
> ['abc', 'cdf']

Hmm, you are correct Terry, i must have been confusing
file#write() and print() when i wrote all that nonsense.
Thanks for pointing out the error.

> Since the original poster did not copy the traceback from
> the print error, it is unclear what the error was.

I'm wondering what she is expecting this line to do: 


My understanding is that print is a one way destination to a
stream, and the only return value would be the default None.
Urm, last time i got myself into trouble by not testing,
not letting that happen again! O:-)

py> from __future__ import print_function
py> print([1,2,3])
[1, 2, 3]
py> print(print([1,2,3]))
[1, 2, 3]
py> returnvalue = print([1,2,3])
[1, 2, 3]
py> repr(returnvalue)

Seems like she'd better do the decoding before printing, or
am i wrong again?

More information about the Python-list mailing list