Max Ischenko wrote:
Simon,

This is nice and I'd tend to agree with you if I woudn't get that
UnicodeDecodeError.

How would you advice me to go on then?

This idiom was used in a previous incarnation to set all erroneous fields to None.

    args, kw = tg_util.to_kw(func, args, kw, 1)
    if isinstance(tg_errors, dict):
        kw.update(izip(
                  ifilter(kw.has_key, tg_errors.iterkeys()), repeat(None)))
    args, kw = tg_util.from_kw(func, args, kw, 1)

Where func is the method being called and izip, ifiler and repeat are from itertools. If you are validating only keyword arguments, first and last line can be omited needed.

I do think a more general solution is called for in form of a library function. Any ideas?

Cheers,
Simon

Reply via email to