Python window - encoding problem/special characters

Discussion created by stefan.haglundesri-se-esridist Employee on Oct 4, 2012
Latest reply on Oct 4, 2012 by stefan.haglundesri-se-esridist
Hi All,

How do we best handle special characters when using the python window?

I have this code:
>>> import arcpy
>>> mxd = arcpy.mapping.MapDocument("CURRENT")
... for lyr in arcpy.mapping.ListLayers(mxd):
...  print lyr

which prints out my layers without special characters, but when it gets to the first layer with a special character in the name I get this:
Traceback (most recent call last):
  File "<string>", line 3, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 3: ordinal not in range(128)

So, how can I get around this problem?
(Using 10.1, Build 3035)