A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/111162.html below:

Defining a code object from a function

Defining a code object from a function Defining a code object from a functionSteve Purcell stephen_purcell at yahoo.com
Thu Apr 5 12:29:10 EDT 2001
Neil Benn wrote:
>     I'm using the inspect module to get information about the method
> arguments back.
> 
> However...................
> 
> My problem is that the getargs methods of inspect want a code object.
> Looking through the docs on Python.org I can't work out how to convert a
> method call to a code object so that I can then get the arguments back.
> 
>     Please could someone advise me, pretty please?


Try this:

    >>> import inspect
    >>> class Foo:
    ...   def method(self, arg1, arg2="something"):
    ...     pass
    ... 
    >>> f = Foo()             
    >>> inspect.getargs(f.method.im_func.func_code)
    (['self', 'arg1', 'arg2'], None, None)


-Steve

-- 
Steve Purcell, Pythangelist
Get testing at http://pyunit.sourceforge.net/
Any opinions expressed herein are my own and not necessarily those of Yahoo


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4