Re: How do I encode and decode this data to write to a file?

2013-05-01 Thread Ned Batchelder
On 5/1/2013 5:20 PM, Tony the Tiger wrote: On Mon, 29 Apr 2013 10:47:46 +0100, cl wrote: raw = os.path.join(directory, self.getNameNoExtension()) + .html file = open(raw, w) file.write(.join(html).encode('utf-8')) file.close() This works for me:

Re: How do I encode and decode this data to write to a file?

2013-05-01 Thread Ned Batchelder
On 4/29/2013 5:47 AM, c...@isbd.net wrote: If I understand correctly the encode() is saying that it can't understand the data in the html because there's a character 0xc3 in it. I *think* this means that the é is encoded in UTF-8 already in the incoming data stream (should be as my system is

How do I encode and decode this data to write to a file?

2013-04-29 Thread cl
I am debugging some code that creates a static HTML gallery from a directory hierarchy full of images. It's this package:- https://pypi.python.org/pypi/Gallery2.py/2.0 It's basically working and does pretty much what I want so I'm happy to put some effort into it and fix things. The problem

Re: How do I encode and decode this data to write to a file?

2013-04-29 Thread Andrew Berg
On 2013.04.29 04:47, c...@isbd.net wrote: If I understand correctly the encode() is saying that it can't understand the data in the html because there's a character 0xc3 in it. I *think* this means that the é is encoded in UTF-8 already in the incoming data stream (should be as my system is

Re: How do I encode and decode this data to write to a file?

2013-04-29 Thread Peter Otten
c...@isbd.net wrote: I am debugging some code that creates a static HTML gallery from a directory hierarchy full of images. It's this package:- https://pypi.python.org/pypi/Gallery2.py/2.0 It's basically working and does pretty much what I want so I'm happy to put some effort into it

Re: How do I encode and decode this data to write to a file?

2013-04-29 Thread Dave Angel
On 04/29/2013 05:47 AM, c...@isbd.net wrote: A couple of generic comments: your email program made a mess of the traceback by appending each source line to the location information. Please mention your Python version OS. Apparently you're running 2.7 on Linux or similar. I am debugging

Re: How do I encode and decode this data to write to a file?

2013-04-29 Thread cl
Andrew Berg bahamutzero8...@gmail.com wrote: On 2013.04.29 04:47, c...@isbd.net wrote: If I understand correctly the encode() is saying that it can't understand the data in the html because there's a character 0xc3 in it. I *think* this means that the é is encoded in UTF-8 already in the

Re: How do I encode and decode this data to write to a file?

2013-04-29 Thread cl
Dave Angel da...@davea.name wrote: On 04/29/2013 05:47 AM, c...@isbd.net wrote: A couple of generic comments: your email program made a mess of the traceback by appending each source line to the location information. What's me email program got to do with it? :-) I'm using a dedicated

Re: How do I encode and decode this data to write to a file?

2013-04-29 Thread Robert Kern
On 2013-04-29 13:59, c...@isbd.net wrote: Dave Angel da...@davea.name wrote: On 04/29/2013 05:47 AM, c...@isbd.net wrote: A couple of generic comments: your email program made a mess of the traceback by appending each source line to the location information. What's me email program got to

Re: How do I encode and decode this data to write to a file?

2013-04-29 Thread cl
Robert Kern robert.k...@gmail.com wrote: On 2013-04-29 13:59, c...@isbd.net wrote: Dave Angel da...@davea.name wrote: On 04/29/2013 05:47 AM, c...@isbd.net wrote: A couple of generic comments: your email program made a mess of the traceback by appending each source line to the location

Re: How do I encode and decode this data to write to a file?

2013-04-29 Thread Skip Montanaro
How strange. I think it must be something to do with the gmane interface between news and mail then. Probably. It was borked in Gmail as well... Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I encode and decode this data to write to a file?

2013-04-29 Thread Terry Jan Reedy
On 4/29/2013 5:47 AM, c...@isbd.net wrote: case). Here's the traceback:- File /usr/local/lib/python2.7/dist-packages/gallery/picture.py, line 361, in createPictureHTML file.write(.join(html).encode('utf-8')) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 783: