473,386 Members | 1,815 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,386 software developers and data experts.

sys._getframe() not behaving as expected


sys._getframe() is acting peculiar. At least it doesn't seem to be doing
what I expect based upon a couple readings of its doc. Given this module
(call it 'gl'):

import sys

def printframes():
print "frame[-2]:", id(sys._getframe(-2))
print "frame[-1]:", id(sys._getframe(-1))
print "frame[0]:", id(sys._getframe(0))
print "frame[-2] globals:", id(sys._getframe(-2).f_globals)
print "frame[-1] globals:", id(sys._getframe(-1).f_globals)
print "frame[0] globals:", id(sys._getframe(0).f_globals)
print "my globals:", id(globals())

calling it like so from the interpreter prompt (CVS):
import gl
def f(): ... gl.printframes()
... f() frame[-2]: 3822448
frame[-1]: 3822448
frame[0]: 3822448
frame[-2] globals: 11889232
frame[-1] globals: 11889232
frame[0] globals: 11889232
my globals: 11889232 id(globals())

3955136

The gl.printframes() function never prints the id of the interpreter's
globals(), nor does it ever print different frames. What am I missing? I
would like to get a handle on the globals for the frame from which
printframes() is called.

Skip

Jul 18 '05 #1
0 959

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

Similar topics

5
by: Matt Bostock | last post by:
Hi, Please see: http://www.drfunkenstein.net/catalogue/categories/fancydress/81/go/2/ ...and try clicking on the '< previous' link underneath the costume thumbnails. The link is only...
4
by: Drew Lettington | last post by:
I'm making a simple call to display error messages in a MessageBox from a Windows form and the MessageBox is not behaving in a modal fashion. My modal form displays, the user clicks a button and...
5
by: amit kumar | last post by:
I am calling a function which returns pointer to a map. The declaration of the map is map<int,vectxyz*>. vectxyz is a vector containing pointer to a class xyz. For map<int,vectxyz*>* p1 In the...
8
by: DamonChong | last post by:
Hi, I am new and had this piece of code which I created but it is not behaving as expected. I'm using g++, can someone help me out? Thank you. //--------file (Object.cc)----------- class Object...
0
by: elime | last post by:
Hi all I have a strange behaving on some PC with my DataGrid. It only occurs on some PC, on others it works perfectly fine. ->(same ..net version installed) it's very confusing. starting...
3
by: Steve - DND | last post by:
I just implemented a page that performs a Response.Redirect(url, true). As such, I wrapped it in a try catch, and explicitly caught a ThreadAbortException. However, the thread abort exception was...
3
by: Kevin Macdonald | last post by:
I expected Postgresql to use an indexed access method, but in certain cases it is using a sequential scan. Details are below: Table: P1_NRN_ROAD ( sobjid int8 primary key, v int8...
1
by: SteveT | last post by:
Folks, I am reading/writing data within an XML file. In my form I have a label that is assigned to the UpdateDate field within the XML file. Within the form I update the label to a different...
0
by: Patrick A | last post by:
I have created a file DSN on my PC, and am using it to provide one of the two connections required for an Access query. (The other connection uses the PostGRE SQL connection and works as...
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: 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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...

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.