Request for a change in the csv module.

Paulo da Silva psdasilvaX at esotericaX.ptX
Tue Mar 13 17:15:19 CET 2007


Diez B. Roggisch escreveu:
> Paulo da Silva wrote:
...

> 
> That it does convert non-string-values to strings when writing could be seen
> as convenience, or actual bug as it might cause troubles as you perceived
> them - but the solution would clearly be to get rid of this functionality,
> not enhance it.


It's just a matter of
personal opinion, and IMO, taking in consideration what other python
modules provide, a csv module should make the appropriate data
conversions. It is simple to implement for most (all?) cases and it will
bring a lot of functionality. You just output things.
In csv output you don't need special data formats. Only the data to the
most available precision. Dates are a very special case, as are the
separators, line terminators, etc.

The python way of exporting this data should be something like:
	class MyDialect(Dialect):
		...
		locale="pt_PT at euro"
		dateformat="YYYY-MM-DD hh:mm:ss"

	...
	w=csv.writer(f,dialect=MyDialect)
	w.writerows(foo)

Frequent tasks should be done by the modules. Not by the users.
And csv is unusable without output formatting. This is particulary true
if, as you said, the csv didn't provide any conversion at all.
So, why force the programmers to repeat the same tedious procedures
whenever they want to use csv, not to talk about the lack of performance
that implies?



More information about the Python-list mailing list