Python: How do I create a reference to a reference?
- by KCArpe
Hi,
I am traditionally a Perl and C++ programmer, so apologies in advance if I am misunderstanding something trivial about Python!
I would like to create a reference to a reference.
Huh? Ok. All objects in Python are actually references to the real object.
So, how do I create a reference to this reference?
Why do I need/want this? I am overriding sys.stdout and sys.stderr to create a logging library. I would like a (second-level) reference to sys.stdout.
If I could create a reference to a reference, then I could create a generic logger class where the init function receives a reference to a file handle reference that will be overrided, e.g., sys.stdout or sys.stderr. Currently, I must hard-code both values.
Cheers,
Kevin