Can anyone suggest how I can include some debugging in a Python script? I don't suppose there is any way to single-step through a program is there? -- John
From: "John Poltorak" <jp@warpix.org>
Can anyone suggest how I can include some debugging in a Python script?
I don't suppose there is any way to single-step through a program is there?
Not that I have discovered - I hope someone else can prove me wrong! However, you can wrap your entire script in a 'try/except' and use a list variable to collect debug info along the way and then print it out. Eg. try: debuglist = [] some code debuglist.append('at point 1, somevar='+somevar) some more code debuglist.append('at point 2, anothervar='+anothervar) except: return debuglist Note: if you are using the 'Test' (ie. click on the Test tab while you are editing the script within the ZMI) instead of 'return debuglist' use 'print debuglist' HTH Jonathan
On Sat, Mar 20, 2004 at 03:21:25PM -0500, Small Business Services wrote:
From: "John Poltorak" <jp@warpix.org>
Can anyone suggest how I can include some debugging in a Python script?
I don't suppose there is any way to single-step through a program is there?
Not that I have discovered - I hope someone else can prove me wrong!
However, you can wrap your entire script in a 'try/except' and use a list variable to collect debug info along the way and then print it out.
What I was hoping for was something like the '-x' flag for shell scripts. I guess I could try using '-v' and see what happens. There is also a PYTHONVERBOSE=x variable which can be used. If anyone has experience of those I'd be interested in any advice.
Note: if you are using the 'Test' (ie. click on the Test tab while you are editing the script within the ZMI) instead of 'return debuglist' use 'print debuglist'
I can't do that since it is the Zope install script I am trying to debug...
HTH
Jonathan
-- John
John Poltorak wrote:
I can't do that since it is the Zope install script I am trying to debug...
That's much easier, pdb is your friend: http://www.python.org/doc/current/lib/module-pdb.html Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
On Mon, Mar 22, 2004 at 04:46:14PM +0000, Chris Withers wrote:
John Poltorak wrote:
I can't do that since it is the Zope install script I am trying to debug...
That's much easier, pdb is your friend:
In this case I only needed to add '-v' as a command line option to see where things were going wrong.
Chris
-- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
-- John
I hear this is possible with Boa Constructor. Stefan --On Samstag, 20. März 2004 20:02 +0000 John Poltorak <jp@warpix.org> wrote:
Can anyone suggest how I can include some debugging in a Python script?
I don't suppose there is any way to single-step through a program is there?
-- The time has come to start talking about whether the emperor is as well dressed as we are supposed to think he is. /Pete McBreen/
I wrote http://zope.org/Members/peterbe/w2f to solve the problem you seem to have. Feel free to use and abuse it. John Poltorak wrote:
Can anyone suggest how I can include some debugging in a Python script?
I don't suppose there is any way to single-step through a program is there?
-- Peter Bengtsson, http://www.peterbe.com
On Sat, Mar 20, 2004 at 08:02:08PM +0000, John Poltorak wrote:
Can anyone suggest how I can include some debugging in a Python script?
I don't suppose there is any way to single-step through a program is there?
I suggest that you read "Conversing with Zope". <http://www.zope.org/Members/klm/ZopeDebugging/ConversingWithZope> With Zope 2.7 you don't need to install the 'izctl' script mentioned in that document. You can just use 'zopectl debug' to start ZServer under control of a Python command shell. -- Fred Yankowski fred@ontosys.com tel: +1.630.879.1312 OntoSys, Inc PGP keyID: 7B449345 fax: +1.630.879.1370 www.ontosys.com 38W242 Deerpath Rd, Batavia, IL 60510-9461, USA
On Sun, Mar 21, 2004 at 08:33:41AM -0600, Fred Yankowski wrote:
On Sat, Mar 20, 2004 at 08:02:08PM +0000, John Poltorak wrote:
Can anyone suggest how I can include some debugging in a Python script?
I don't suppose there is any way to single-step through a program is there?
With Zope 2.7 you don't need to install the 'izctl' script mentioned in that document. You can just use 'zopectl debug' to start ZServer under control of a Python command shell.
The problem I was trying to sort out was the actual install of Zope ;-)...
-- Fred Yankowski fred@ontosys.com tel: +1.630.879.1312 OntoSys, Inc PGP keyID: 7B449345 fax: +1.630.879.1370 www.ontosys.com 38W242 Deerpath Rd, Batavia, IL 60510-9461, USA
-- John
John Poltorak wrote at 2004-3-20 20:02 +0000:
I don't suppose there is any way to single-step through a program is there?
It is. You have several options: * the Python debugger ("pdb"), see its documentation in the Python Library Reference * various IDE's for Python. Some of my colleagues are satisfied with the (commercial!) WingIDE. With a patch (to Zope), it is even able to debug Zope's FSPythonScripts. -- Dieter
participants (7)
-
Chris Withers -
Dieter Maurer -
Fred Yankowski -
John Poltorak -
Peter Bengtsson -
Small Business Services -
Stefan H. Holek