Obtaining stack frame

0 votes
How do I get a stack frame to pass into traceback.print_stack?

 Suppose I want to print the stack trace starting one level above the invocation point. How can I do that?
May 3 in Python by ana1504.k
• 6,150 points
10 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
inspect.stack() will get you the current stack as a list. You can pick any frame you want out of it. You can also use inspect.currentframe().f_back to get your caller's frame. Basically, the inspect module is where it's at.
answered May 3 by SDeb
• 9,740 points

Related Questions In Python

0 votes
1 answer

Obtaining a value when given a key in python dicionaries

We cannot. Dictionaries aren't meant to be ...READ MORE

answered May 31, 2018 in Python by Nietzsche's daemon
• 4,260 points
14 views
0 votes
1 answer

How to replace values with None in Pandas data frame in Python?

Actually in later versions of pandas this ...READ MORE

answered Aug 30, 2018 in Python by Priyaj
• 56,120 points
294 views
0 votes
1 answer

How to implement Stack in python

class Stack: def __init__(self): ...READ MORE

answered Nov 15, 2018 in Python by findingbugs
• 3,140 points
17 views
0 votes
1 answer

Crawling after login in Python

You missed a few login data forms, ...READ MORE

answered Sep 7, 2018 in Python by Priyaj
• 56,120 points
131 views
0 votes
1 answer

Crawling after login in Python

You missed a few login data forms, ...READ MORE

answered Sep 14, 2018 in Python by Priyaj
• 56,120 points
22 views
0 votes
1 answer

“stub” __objclass__ in a Python class how to implement it?

You want to avoid interfering with this ...READ MORE

answered Sep 27, 2018 in Python by Priyaj
• 56,120 points
30 views
+1 vote
1 answer

How is raw_input() and input() in python3.x?

raw_input() was renamed to input() so now input() returns the exact string ...READ MORE

answered Oct 30, 2018 in Python by Priyaj
• 56,120 points
26 views
0 votes
1 answer

Is there a stack/heap in Python?

Memory management in Python involves a private ...READ MORE

answered Nov 9, 2018 in Python by SDeb
• 9,740 points
111 views
0 votes
1 answer

How to go to top frame in pdb (python debugger)

You can use a PdbExtension for this. See https://github.com/fschulze/pytest-pdb/pull/5 where ...READ MORE

answered Apr 30 in Python by SDeb
• 9,740 points
8 views
0 votes
1 answer

Filtering R data-frame with multiple conditions

You can use the 'filter' function from ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
2,725 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.