comparing dialects of csv-module

Malte Dik malte.usenet at web.de
Sun Dec 20 10:22:36 EST 2009


quote:
>>>> d = csv.Sniffer().sniff("1,2,3")
>>>> def eq(a, b, attributes=[name for name in dir(d) if not
> name.startswith("_")]):
> ...     return all(getattr(a, n, None) == getattr(b, n, None) for n in
> attributes)

Only change I made is substituting "dir(csv.excel)" or "dir(csv.Dialect)" 
for "dir(d)", because I can't be always sure, that there'd be a nicely 
defined "d".


Salute,

Malte



More information about the Python-list mailing list