473,383 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

List code of function in interpreter

A simple question.

Is it possible in the python (or ipython) interpreter to
review the source code of a self defined function?

Thanks

Erwin
Jul 18 '05 #1
1 1461
a9******@unet.univie.ac.at wrote:
A simple question.

Is it possible in the python (or ipython) interpreter to
review the source code of a self defined function?


That depends. The source is actually "lost" in at least
one sense, because Python is compiled to bytecode (similar
in some ways to how Java works) behind the scenes, and the
interpreter executes this bytecode and not the source.

On the other hand, the source file is still right there, usually,
and if you are looking for a programmatic way of finding it
and listing it, I believe the inspect module is what you are
looking for: http://docs.python.org/lib/module-inspect.html

Another and much less suitable (I suspect) option for you is to
disassemble the function using the dis module.

-Peter
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Helge | last post by:
I wonder how this can be accomplished: I've got a list, containing several strings. The strings look like this: I would like to create one object for each item in the list, and the name...
5
by: Diez B. Roggisch | last post by:
Hi, this strikes me as a pretty basic question, but google didn't help, so I'm asking it here: How do I get a list of functions defined in a module in the module itself? Like this: ---...
6
by: Bernhard | last post by:
Hello, I would like to build a small interpreter (in an c-program), which calls functions with user-defined arguments. To do this, I have a list of functions names (in an array), with the...
2
by: Sam | last post by:
In our C++ program, we are using the system call to execute another C++ program synchronously. The program executed by system runs without error and returns back a 0. Under conditions we cannot...
35
by: Thierry Loiseau | last post by:
Hello all, and Happy end year 2005 ! Well, I would like to obtain a list of all JavaScript var statement, With "for...in" perharps ? That is bellow my recent test here, but the problem is...
1
by: yawgmoth7 | last post by:
Hello, I have a piece of code: command = raw_input("command> ") words = string.split(command, ' ') temparg = words if len(words)<= 3: temparg = words else: temparg = words funcarg =...
6
by: Heiko Wundram | last post by:
Hi all! The following PEP tries to make the case for a slight unification of for statement and list comprehension syntax. Comments appreciated, including on the sample implementation. ===...
16
by: lawrence k | last post by:
I've made it habit to check all returns in my code, and usually, on most projects, I'll have an error function that reports error messages to some central location. I recently worked on a project...
18
by: John Henry | last post by:
If I have a list of say, 10 elements and I need to slice it into irregular size list, I would have to create a bunch of temporary variables and then regroup them afterwords, like: # Just for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.