decode overwrite variable?

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Mon Jan 29 01:47:19 EST 2007


In <21235$45bd8f83$d8a87c2a$18298 at NEXICOM.NET>, Jammer wrote:

> Will a failed decode overwrite the variable?
> 
> message = message.decode('iso-8859-1')
> or do I need to do
> msg = message.decode('iso-8859-1')

Why don't you just try?

In [2]: a = u'\u2022'

In [3]: a = a.decode('iso-8859-1')
---------------------------------------------------------------------------
exceptions.UnicodeEncodeError             Traceback (most recent call last)

/home/marc/<ipython console>

UnicodeEncodeError: 'ascii' codec can't encode character u'\u2022' in position 0: ordinal not in range(128)

In [4]: a
Out[4]: u'\u2022'

Ciao,
	Marc 'BlackJack' Rintsch




More information about the Python-list mailing list