A
Alexander Eberts
I'm new to python so appologies to the group if this question is asked
often. I'm wondering if it's possible to query an object instance to find
out what arguments the instance's __init__ function was called with from
*outside* the class's local namespace. For example, if I define a class Foo
as follows:
import sys
class Foo:
def __init__(self, *args):
print args # no problem here
....and then create an instance of Foo:
('bar', 'bleck')
Now, I'd like to be able to find out what arguments someobj was called with.
So first I tried:
but I get: "AttributeError: args"
so then I tried:
which returns an empty tuple
and then I tried:
File "<interactive input>", line 1, in ?
KeyError: args
No dice.. Is there any way to find out what arguments an object was called
with? Are the args stored with the instance? I scoured the python faq but
there are no answers (that I could see) to this question. Any help would be
much appreciated.
yours,
Alex Eberts
often. I'm wondering if it's possible to query an object instance to find
out what arguments the instance's __init__ function was called with from
*outside* the class's local namespace. For example, if I define a class Foo
as follows:
import sys
class Foo:
def __init__(self, *args):
print args # no problem here
....and then create an instance of Foo:
('bar', 'bleck')
Now, I'd like to be able to find out what arguments someobj was called with.
So first I tried:
but I get: "AttributeError: args"
so then I tried:
which returns an empty tuple
and then I tried:
Traceback (most recent call last):some_obj.__dict__['args']
File "<interactive input>", line 1, in ?
KeyError: args
No dice.. Is there any way to find out what arguments an object was called
with? Are the args stored with the instance? I scoured the python faq but
there are no answers (that I could see) to this question. Any help would be
much appreciated.
yours,
Alex Eberts