inspect.getbloc k() seems to halt prematurely. This code only prints 6
lines of the 12 line input file.
assume it's by design, but the docs don't mention getblock. docstring is
"Extract the block of code at the top of the given list of lines," which
should be "code *from* the top."
###whatiscompil e2.py
import inspect
r = open('thebogusf ile.txt').read( )
code = compile( r, 'thebogusfile.t xt', 'exec' )
exec code
print '***'
print inspect.getsour ce(code)
###thebogusfile .txt
def f(a, b):
print a,
print b,
c = a + b
print c,
return a + b
def g():
print 'g'
print f( 3, 4 ),
g()
###stdout
3 4 7 7 g
***
def f(a, b):
print a,
print b,
c = a + b
print c,
return a + b 0 902 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Hans Georg Krauthaeuser |
last post by:
Dear all,
I have a problem to get the command that has called a function if the
command was given on multiple lines. E.g.:
###################################################
import inspect
def call(a,b,c,d,e):
s = inspector()
|
by: Thomas Guettler |
last post by:
Hi,
the line numbers of inspect.getinnerframes are
different from traceback.format_exception.
This results in wrong lines being shown in cgitb.
An example is below.
I looked at the source of both methods. One uses f_lineno (wrong)
|
by: Fernando Perez |
last post by:
Hi all,
IPython has suffered quite a few problems with the inspect module in python
2.3. For these, unfortunately all I've been able to do is guard with
overreaching except clauses, as I had not been able to find small,
reproducible examples to pass on to the devs. But today I got a crash report
from a user and I've been able to replicate...
|
by: It's me |
last post by:
I discovered the hardway what inspect.isclass() is doing. Consider this no
brainer code:
###
import inspect
class Abc:
def Hello(self):
return
|
by: Ron Adam |
last post by:
While playing around with the inspect module I found that the
Blockfinder doesn't recognize single line function definitions.
Adding the following two lines to it fixes it, but I'm not sure if it
causes any problems anywhere else.
elif self.indent == 0:
raise EndOfBlock, self.last
Cheers,
| |
by: aj |
last post by:
What is the difference (if any) between
inspect check database
and
db2dart
???
Do they both find the same potential problems? Does one
provide more comprehensive checking than the other?
TIA
|
by: Chris Pax |
last post by:
Hello,
I recently been trying to use the inspect module to inspect the
arguments of gtk objects, such as gtk.Button. I tried like this:
inspect.getargspec(gtk.Button.__init__)
and get the fallowing error:
File "<stdin>", line 1, in <module>
|
by: Aaron \Castironpi\ Brady |
last post by:
Hello,
The 'inspect' module has this method:
inspect.getargvalues(frame)
It takes a frame and returns the parameters used to call it, including
the locals as defined in the frame, as shown.
.... import inspect
|
by: rajasankar |
last post by:
Hi,
I am using Jython based application and trying to use inspect.py in the python files.
Here is my code
import inspect,os,sys,pprint,imp
def handle_stackframe_without_leak(getframe):
frame = inspect.currentframe()
try:
function = inspect.getframeinfo(getframe)
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |