adding attributes to builtin functions

Peter Hansen peter at engcorp.com
Mon Jun 24 22:32:54 EDT 2002


Douglas Zongker wrote:
> 
> Well, that works, but what I *really* wanted to do was to set the
> attributes from within C.  I tried something like this:
> [...]
> but it gives the same exception as doing it in Python ("builtin
> function has read-only attributes").  I was hoping if someone could
> tell me how to do it in Python I could translate that back into C...

Well, since as it says the item has read-only attributes, I 
don't suppose you _can_ do it, even in Python.  Or you can
do what I showed, but from C.  

Maybe at this point you need to ask and answer the question "why?".  
There's often a better approach when you get stumped by something
like this.  What's your real goal in doing this?

(I've never had a use for function attributes and I'm not sure 
I ever will.  Maybe it's just me... I do tend to avoid anything
that's not just "vanilla" code though, to keep myself sane.)

-Peter



More information about the Python-list mailing list