I asked this before, but got no response, but I KNOW YOU KNOW ;-)
A year or so ago, I was given a really useful answer to a question posed
here, which showed me how to start the debugger from withing a script.
Yes, of course I've lost the mail (and I have trawled through all my old
mail), and yes, I know I'm stupid!
I'm surprised this isn't a FAQ, BTW, as it seems such a useful facility.
So come on guys, cough it up!
Thanks
Graham Nicholls
--
#include <wit> 8 1583
Graham Nicholls wrote: A year or so ago, I was given a really useful answer to a question posed here, which showed me how to start the debugger from withing a script.
Are you looking for pdb.set_trace() ?
Peter
Peter Otten wrote: Graham Nicholls wrote:
A year or so ago, I was given a really useful answer to a question posed here, which showed me how to start the debugger from withing a script.
Are you looking for pdb.set_trace() ?
Peter
I think so, thanks!
Graham
--
#include <wit>
Graham Nicholls wrote: Peter Otten wrote:
Graham Nicholls wrote:
A year or so ago, I was given a really useful answer to a question posed here, which showed me how to start the debugger from withing a script.
Are you looking for pdb.set_trace() ?
Peter I think so, thanks! Graham
Or maybe not.
I'm sure I was able to print the value of variables like this:
except :
pdb.set_trace()
run the program:
error message
(Pdb) d <return> (not sure why!)
(Pdb) print dentry.path
(Pdb) more debugging here
But pdb complains that there are no such variables. It may be that I had to
add some incantation around the script startup - I just can't remember (and
its frustrating!).
Thanks
Graham
--
#include <wit>
Graham Nicholls wrote: I'm sure I was able to print the value of variables like this:
except : pdb.set_trace()
[...] But pdb complains that there are no such variables. It may be that I had to add some incantation around the script startup - I just can't remember (and its frustrating!).
<debugger.py>
import pdb
abc = 1
try:
print "before"
1/0
except:
pdb.set_trace()
print "after"
</debugger.py>
Now run it:
before
--Return-- /(suppressed)/python2.3/pdb.py(992)set_ trace()->None
-> Pdb().set_trace ()
(Pdb) abc
*** NameError: name 'abc' is not defined
(Pdb) u /(suppressed)/debugger.py(7)? ()
-> pdb.set_trace()
(Pdb) abc
1
(Pdb)
If the above sample session doesn't help, you could actually read the pdb
documentation - or do something new and dangerous: search google groups
for, say, Nicholls and set_trace :-)
Peter
Graham Nicholls fed this fish to the penguins on Sunday 04 January 2004
11:27 am: But pdb complains that there are no such variables. It may be that I had to add some incantation around the script startup - I just can't remember (and its frustrating!).
Did you remember to import pdb at the start?
-- =============== =============== =============== =============== == < wl*****@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG < wu******@dm.net | Bestiaria Support Staff < =============== =============== =============== =============== == < Bestiaria Home Page: http://www.beastie.dm.net/ < Home Page: http://www.dm.net/~wulfraed/ <
Peter Otten wrote: Graham Nicholls wrote:
I'm sure I was able to print the value of variables like this:
except : pdb.set_trace() [...] But pdb complains that there are no such variables. It may be that I had to add some incantation around the script startup - I just can't remember (and its frustrating!).
<debugger.py> import pdb abc = 1 try: print "before" 1/0 except: pdb.set_trace() print "after" </debugger.py>
Now run it:
before --Return-- /(suppressed)/python2.3/pdb.py(992)set_ trace()->None -> Pdb().set_trace () (Pdb) abc *** NameError: name 'abc' is not defined (Pdb) u /(suppressed)/debugger.py(7)? () -> pdb.set_trace() (Pdb) abc 1 (Pdb)
If the above sample session doesn't help, you could actually read the pdb
I have had a look, but its rather a case of you don't know what you don't
know, IYSWIM. documentation - or do something new and dangerous: search google groups for, say, Nicholls and set_trace :-)
What a good idea!
Thanks again
PS 1 minute later and I've found the relevant posting, which indeed mentions
using set_trace().
I have in ordinary google searches of course returned ng postings, but had
never used their group searches, so thnkas on two counts. Peter
Regards
Graham
--
#include <wit>
Peter Otten wrote: Graham Nicholls wrote:
.... But pdb complains that there are no such variables. It may be that I had to add some incantation around the script startup - I just can't remember (and its frustrating!).
....
-> Pdb().set_trace () (Pdb) abc *** NameError: name 'abc' is not defined (Pdb) u
This is the key line, 'n' would work as well. The reason your variables
weren't being found is that you were still inside the call to
set_trace(). You need to return from that (either by going "u"p to the
calling context, or to the "n"ext instruction, which returns to the
calling context by finishing the set_trace() call).
Enjoy,
Mike
_______________ _______________ _________
Mike C. Fletcher
Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/
"Mike C. Fletcher" wrote: Peter Otten wrote:
Graham Nicholls wrote:
...
But pdb complains that there are no such variables. It may be that I had to add some incantation around the script startup - I just can't remember (and its frustrating!).
...
-> Pdb().set_trace () (Pdb) abc *** NameError: name 'abc' is not defined (Pdb) u
This is the key line, 'n' would work as well. The reason your variables weren't being found is that you were still inside the call to set_trace(). You need to return from that (either by going "u"p to the calling context, or to the "n"ext instruction, which returns to the calling context by finishing the set_trace() call).
"r" (for "return") works as well....
Wow! Three obvious ways to do the same thing. ;-)
-Peter This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bob |
last post by:
Hi,
I'm trying to build a PHP page which launches another php script to be run
in the background. The web page should return immediately, while the
background script may run for 10 minutes or something. Unfortunately I'm
getting all kinds of weird behaviour..
In my main script I'm using exec() (also tried the other options) to start a
..bat file. This actually works, the batch file is launched and is able to
write something to disk.....
|
by: David |
last post by:
Hello. I've written a page for an intranet that gives the user the
option of launching a Word or PowerPoint document.
The code I used to force the hyperlink to launch the application
rather than open the file in a browser is:
<script language="JavaScript">
function startPowerPoint(strFile)
{
var myApp = new ActiveXObject("PowerPoint.Application");
|
by: VA |
last post by:
I have a report that is accessible by a URL.
How would I go about automating the launching of this URL using, say, a
batch file?
I can put
start iexplore.exe "http://my.url"
in the .bat file
|
by: LordHog |
last post by:
Hello all,
I was wondering what is the best method of launching an
application/exectable from within the Managed VC++ environment? I have
found some information which describe CreateProcess and
ShellExecute(Ex), but I was wondering if there is a perferred way of
performing this task in Managed VC++ that use Windows Forms?
I am trying to launch Notepad from within my application and passing
it a filename as an argument. Any help is...
|
by: Water Cooler v2 |
last post by:
I have a Windows Service I am writing in C# and a set of, let us say
three, other executables written in C# (mostly console applications).
I want that the Windows Service must do so every few seconds:
Check to see if each of the other executables are running or not. If
they are not running, it should load them.
For this purpose, I am planning the following:
| |
by: microb0x |
last post by:
Is there any difference in the way an Access .mdb file is launched from
directly double-clicking the file through windows explorer versus using
code within another Access file to launch the same file?
Here is my situation:
I have an application that when launched does a check whether or not
|
by: Andrew Neiderer |
last post by:
I think I am asking the right newsgroup. If not maybe someone could
tell me where to ask this "beginner" question.
I want to click on an image (.jpg) that launches a Microsoft window
(cmd.exe or command.com) which executes some .exe, e.g googleearth.exe.
I know this is simple
for most of you but I am just starting XHTML. I think it begins with
<html>
<body>
|
by: =?iso-8859-1?B?QW5kcuk=?= |
last post by:
I would like to find out how I can launch an independent Python
program from existing one in a cross-platform way. The result I am
after is that a new terminal window should open (for io independent of
the original script).
The following seems to work correctly under Ubuntu and Windows ... but
I haven't been able to find a way to make it work under Mac OS.
def exec_external(code, path):
"""execute code in an external process
|
by: Oriane |
last post by:
Hi there,
I would like to run a javascript file directly from the desktop, like a
VBScript file. So my post is perhaps "out of topic" in which case I
apologize.
The goal is to run this sort of script, which in turn will open an HTML page
inside a Windows window:
"window.open (http://www..., arg...)"
|
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |