print the code which defined a lambda function

<>

This question already has an answer here:

Answers


As long as you save your code to a source file you can retrieve the source code of an object using the inspect module.

example: open editor type:

myfunction = lambda x: x==2

save as lamtest.py

open shell type python to get to interactive python type the following:

>>>from lamtest import myfunc
>>>import inspect
>>>inspect.getsource(myfunc)

the result:

'myfunc = lambda x: x==2\n'

Need Your Help

Perl defining undefined keys

perl hash key undefined autovivification

The following code prints Key defined 3.

Passing parameters to Guice @Provides method

guice

I have a Guice module that has a @Provides method that takes 2 parameters and returns the implementation of the interface:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.