473,387 Members | 3,821 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,387 software developers and data experts.

Debugging with SciTE

I just figured out a reasonably decent way to use pdb in SciTE for
debugging Python scripts. Debugging takes place in the SciTE output
window. I have only tested this with SciTE on Windows.

Here are the pieces you need:

1. Create a debug.py script file (I save this in
c:\usr\python\scripts):
import sys
from pdb import pm, set_trace
from inspect import getmembers
if sys.platform == 'win32':
import os
os.environ['HOME'] = os.path.join(os.environ['HOMEDRIVE'],
os.environ['HOMEPATH'])
del sys.argv[0]
execfile(sys.argv[0])

2. Create a .pdbrc file in HOME (optional, but very useful):
#Print instance variables (usage "pi classInst")
alias pi for k in %1.__dict__.keys(): print "%1."+k,"=",%1.__dict__[k]
#Print instance variables in self
alias ps pi self
#pprint locals
alias ppl pp locals()
#pprint globals
alias ppg pp globals()
#pprint getmembers
alias ppm pp getmembers(%1)

3. Modify the Build line of the Scite Python.properties file:
# Use python instead of pythonw on non-windows platforms
command.build.*.py=pythonw -i -u c:\usr\python\scripts\debug.py
"$(FileNameExt)"
command.build.subsystem.*.py=1

Now if you hit F7 when editing a Python script, output will be sent to
the
SciTE output window, after which you will see a python prompt. Assuming
there is an exception, entering pm() will start post-mortem debugging,
and you will see the (Pdb) prompt. You can then use pdb commands and
aliases to inspect variable values.

To set a break point in your script, enter set_trace() at the
appropriate point. This will fire up pdb, and you can use s (step) to
step through the code, and the aliases in .pdbrc to list values.

Use Ctrl-Break to kill the debugging session.

You have to be carefull how you type in the output window. Backspaces
tend to confuse things, so you need to make sure your typing is right
the first time. .pdbrc aliases help to reduce typing, so make use of
them.

Cheers,
Jim

Oct 29 '05 #1
1 3802
Based on information from Jarek Zgoda in another thread on the Windows
USERPROFILE environment variable, debug.py should be:
import sys
from pdb import pm, set_trace
from inspect import getmembers
if sys.platform == 'win32':
import os
os.environ['HOME'] = os.environ['USERPROFILE']
del sys.argv[0]
execfile(sys.argv[0])

Oct 29 '05 #2

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

Similar topics

1
by: Nuff Said | last post by:
Question: Is there a way to unfold a Python class *without* unfolding all its methods etc. so that you can get a quick overview of the class? Details: I normally open a file either with...
3
by: Brent W. Hughes | last post by:
I want to increase the number of files I can have open in the SciTE editor. The SciTEDoc.html document says to change the number of buffers in a file called SciTE.properties, but it doesn't say...
32
by: Sticks | last post by:
i'm new to python and i was wondering what editors people prefer to use and why.
2
by: Konrad Koller | last post by:
Under Windows print formatting (header, footer etc.) is OK. Under LINUX it does not work. SciTEGlobal.properties state around line 352: # Printing - only works on Windows Why? How is print...
1
by: Grant Edwards | last post by:
This is technically off-topic, but scite/scinitilla seems to have a particular connection to the Python community. I just tried scite for the first time and rather like it. It uses GTK, which...
1
by: Sandy | last post by:
Dear Pythonic People, I recently discovered SciTE (1.68) as a programming editor, and I find it just beautiful. Small, fast, elegant and beautiful. I particularly like syntax highlighting...
4
by: John Ladasky | last post by:
Hi there. The following minimal code in Python 2.3.4 works under Idle v. 1.0.3, but not under SciTE v. 1.66: from time import sleep try: while True: sleep(0.25) print ".",
4
by: Billy | last post by:
Hi! I'm using: -Compiler: Borland Command Line C++ Compiler 5.5.1 -Code Editor: SciTE 1.75 Anybody know how we can in Scite with command Tools|Go (F5) compile and run my c or cpp program at...
3
by: SteveD | last post by:
Hi guys, http://luaforge.net/frs/?group_id=327 pgdb.zip is an addition to scite-debug, which adds source debugging to the popular SciTE programmer's editor. gdbpy.zip is a standalone version...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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
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
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...
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.