Any way to set or overwrite the __line__ and __file__ metadata?

Posted by charles.merriam on Stack Overflow See other posts from Stack Overflow or by charles.merriam
Published on 2010-03-12T06:34:43Z Indexed on 2010/03/12 6:37 UTC
Read the original article Hit count: 236

Filed under:
|
|
|
|

I'm writing some code that needs to change function signatures. Right now, I'm using Simionato's FunctionMaker class, which uses the (hacky) inspect module, and does a compile. Unfortunately, this still loses the line and file metadata.

Does anyone know:

  • If it is possible to overwrite these values in some odd way?
  • If hacking up a class with a complex getattribute() to intercept the values and also try to make the class looks like a function is any more possible than a moose with a flying nun hat?
  • Is there an alternative to the (hacky) inspect module? PEP 362 is dead dead dead?
  • I know decorators and cPickle users fight with this. What other situations is the read only metadata in people's way?

I appreciate any insights. Thank you.

© Stack Overflow or respective owner

Related posts about python

Related posts about decorators