Any comment on using ctypesgen package?

Chris Angelico rosuav at gmail.com
Sat Mar 5 00:49:50 EST 2016


On Sat, Mar 5, 2016 at 4:35 PM,  <jfong at ms4.hinet.net> wrote:
> After taking Chris's suggestion, the installation is pushing forward a little and then bump into another error:
> ----------
> File "D:\Patch\ctypesgen-master\ctypesgencore\parser\pplexer.py", line 123, in
> punctuator_regex
>     punctuator_regexes.sort(lambda a, b: -cmp(len(a), len(b)))
> TypeError: must use keyword argument for key function
> ----------
> This error has been mentioned in "Sorting HOW TO" section in 3.4 document,
>     "In Py3.0, the cmp parameter was removed entirely"
>     "To convert to a key function, just wrap the old comparison function:"
>     "In Python 3.2, the functools.cmp_to_key() function was added to the functools module in the standard library."
>
> Oh, goodness! do I have to dive into 2.x?
>
> Based on the assumptions below:
> 1. It might be not easy to upgrade it to 3.x (at least not just run 2To3), or else its author will not drop it.
> 2. I have to go back into 2.x jungle to study all these difference.
> 3. Even "Python setup.py install" passed, it's still not sure if the output will be correct.
>
> I think it's better to drop it too. Thanks for your advice, Chris and Peter.

Your conclusion may well be correct. However, the exact issue you're
looking at here might be easily enough fixed; it looks like it's
trying to sort things by length, so you can simply use "key=len" (and
maybe "reverse=True").

ChrisA



More information about the Python-list mailing list