Paulo da Silva schrieb:
> [EMAIL PROTECTED] escreveu:
>> On Mar 12, 4:26 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote:
> ...
>
>> locale.setlocale(locale.LC_NUMERIC, 'pt_BR.ISO8859-1')
>> csv_writer = csv.writer(open("foo.csv","w"), dialect='excel')
>> rows = (('testing', 1.23), ('testing', 2.34))
>> formatted_rows = ((string, locale.format('%g', number)) for
>> (string,number) in rows)
>> csv_writer.writerows(formatted_rows)
>
>
> That works but it is a pain to use.
Why? I think it's straightforward.
> May be I'll sublass csv or even I'll write one myself.
> It would be much better to be able to specify an additional
> variabel to the Dialect class and change csv.
I don't think so. The csv module is about the subtleties that can occur
when parsing textual data with possible escape chars and the like, and
creating that data.
But IHMO its up to the user to feed it with just textual data. Because
automatically converting numbers falls flat on it's face in case of
special requirements like a limit on the number of digits to render and
the like. Better do that in a simple and straightforward preprocessing
state, as shown above.
The same is essentially true for dates as well, btw. How do you want to
deal with them?
Diez
--
http://mail.python.org/mailman/listinfo/python-list