get function arguments
Jorge Godoy
godoy at ieee.org
Tue Nov 16 15:25:11 EST 2004
More information about the Python-list mailing list
Tue Nov 16 15:25:11 EST 2004
- Previous message (by thread): get function arguments
- Next message (by thread): get function arguments
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Steven Bethard <steven.bethard at gmail.com> writes: > Benny Mohr <news5 <at> bennymo.ch> writes: >> >> How can I get the list of argumens of this function? > > Is this what you mean? > >>>> def myFunc(a,b,c='default'): > ... pass > ... >>>> myFunc.func_code.co_varnames > ('a', 'b', 'c') > > I don't know where (if?) the func_code attributes are documented, but you should > be able to figure them out with a little object introspection (e.g. dir or an > editor like PythonWin that does some code completion). You could have asked in the interactive prompt as well :-) >>> dir(myFunc.func_code) ['__class__', '__cmp__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'co_argcount', 'co_cellvars', 'co_code', 'co_consts', 'co_filename', 'co_firstlineno', 'co_flags', 'co_freevars', 'co_lnotab', 'co_name', 'co_names', 'co_nlocals', 'co_stacksize', 'co_varnames'] >>> There seems to be other interesting things here too: >>> dir(myFunc) ['__call__', '__class__', '__delattr__', '__dict__', '__doc__', '__get__', '__getattribute__', '__hash__', '__init__', '__module__', '__name__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc', 'func_globals', 'func_name'] >>> -- Godoy. <godoy at ieee.org>
- Previous message (by thread): get function arguments
- Next message (by thread): get function arguments
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list