monkey patching __code__

Sven R. Kunze srkunze at mail.de
Fri Mar 18 10:32:09 EDT 2016


On 18.03.2016 14:47, Ian Kelly wrote:
> Your patched version takes two extra arguments. Did you add the
> defaults for those to the function's __defaults__ attribute?

That's it! :-) Thanks a lot.

Just to understand this better: why is that not part of the code object 
but part of the function?

> This sounds like a pretty hairy thing that you're trying to do. Surely
> there must be some better way to accomplish the same goal.

We are open for suggestions. We featured our own reverse function for a 
while but it lead to inconsistent behaviors across the field. Especially 
considering that Django provides an {% url %} template tag which would 
then use yet another reverse implementation.

Best,
Sven



More information about the Python-list mailing list