[Python-Dev] namedtuple implementation grumble
Chris Withers
chris at simplistix.co.uk
Fri Jun 6 20:50:57 CEST 2014
Hi All,
I've been trying to add support for explicit comparison of namedtuples
into testfixtures and hit a problem which lead me to read the source and
be sad.
Rather than the mixin and class assembly in the function I expected to
find, I'm greeted by an exec of a string.
Curious as to what lead to that implementation approach? What does it
buy that couldn't have been obtained by a mixin providing the functionality?
In my case, that's somewhat irrelevant, I'm looking to store a comparer
in a registry that would get used for all namedtuples, but I have
nothing to key that off, there are no shared bases other than object and
tuple.
I guess I could duck-type it based on the _fields attribute but that
feels implicit and fragile.
What do you guys suggest?
cheers,
Chris
--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
More information about the Python-Dev
mailing list