Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33378 > unrolled thread
| Started by | chip9munk@gmail.com |
|---|---|
| First post | 2012-11-15 04:29 -0800 |
| Last post | 2012-11-15 06:27 -0800 |
| Articles | 17 — 9 participants |
Back to article view | Back to comp.lang.python
debugging in eclipse chip9munk@gmail.com - 2012-11-15 04:29 -0800
Re: debugging in eclipse Roy Smith <roy@panix.com> - 2012-11-15 07:49 -0500
Re: debugging in eclipse chip9munk@gmail.com - 2012-11-15 05:43 -0800
Re: debugging in eclipse Dave Angel <d@davea.name> - 2012-11-15 08:41 -0500
Re: debugging in eclipse chip9munk@gmail.com - 2012-11-15 05:45 -0800
Re: debugging in eclipse chip9munk@gmail.com - 2012-11-15 05:45 -0800
Re: debugging in eclipse Roy Smith <roy@panix.com> - 2012-11-15 08:54 -0500
Re: debugging in eclipse aahz@pythoncraft.com (Aahz) - 2012-11-15 07:56 -0800
Re: debugging in eclipse Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-15 17:05 +0000
Re: debugging in eclipse alex23 <wuwei23@gmail.com> - 2012-11-15 17:10 -0800
Re: debugging in eclipse Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-16 10:30 +0000
Re: debugging in eclipse "Martin P. Hellwig" <martin.hellwig@gmail.com> - 2012-11-15 05:44 -0800
Re: debugging in eclipse chip9munk@gmail.com - 2012-11-15 05:46 -0800
Re: debugging in eclipse Alister <alister.ware@ntlworld.com> - 2012-11-15 14:21 +0000
Re: debugging in eclipse chip9munk@gmail.com - 2012-11-15 06:28 -0800
Re: debugging in eclipse Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-11-15 14:43 +0100
Re: debugging in eclipse chip9munk@gmail.com - 2012-11-15 06:27 -0800
| From | chip9munk@gmail.com |
|---|---|
| Date | 2012-11-15 04:29 -0800 |
| Subject | debugging in eclipse |
| Message-ID | <b45840eb-f429-4287-905a-76d752d4fe04@googlegroups.com> |
Hi all!
I have a stupid problem, for which I cannot find a solution...
I have a python module, lets call it debugTest.py.
and it contains:
def test():
a=1
b=2
c=a+b
c
so as simple as possible.
Now I would like to debug it in eclipse.. (I have pydev and all)
so the question is how do I debug the test function? (by debug I mean go into it in the debugging mode and execute step by step, inspect the variables and so on.. you know, like it is so easily done in Matlab for example).
I place a break point in the function, run the debugger and it stars and is terminated immediately. (of course it does not know where to go..)
So how can I do this? please help!
Thank you all in advance!
[toc] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2012-11-15 07:49 -0500 |
| Message-ID | <roy-4BE4D2.07492115112012@news.panix.com> |
| In reply to | #33378 |
In article <b45840eb-f429-4287-905a-76d752d4fe04@googlegroups.com>, chip9munk@gmail.com wrote: > Now I would like to debug it in eclipse.. Heh. It took me a while to realize that the subject line was not referring to http://en.wikipedia.org/wiki/Solar_eclipse_of_November_13,_2012
[toc] | [prev] | [next] | [standalone]
| From | chip9munk@gmail.com |
|---|---|
| Date | 2012-11-15 05:43 -0800 |
| Message-ID | <dc3a69fe-a861-4875-9c1d-f0f2676a8de5@googlegroups.com> |
| In reply to | #33379 |
On Thursday, November 15, 2012 1:49:22 PM UTC+1, Roy Smith wrote: > Heh. It took me a while to realize that the subject line was not > referring to > http://en.wikipedia.org/wiki/Solar_eclipse_of_November_13,_2012 :))
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <d@davea.name> |
|---|---|
| Date | 2012-11-15 08:41 -0500 |
| Message-ID | <mailman.3714.1352986928.27098.python-list@python.org> |
| In reply to | #33378 |
On 11/15/2012 07:29 AM, chip9munk@gmail.com wrote: > Hi all! > > I have a stupid problem, for which I cannot find a solution... > > I have a python module, lets call it debugTest.py. > > and it contains: > def test(): > a=1 > b=2 > c=a+b > c > > so as simple as possible. > > Now I would like to debug it in eclipse.. (I have pydev and all) > so the question is how do I debug the test function? (by debug I mean go into it in the debugging mode and execute step by step, inspect the variables and so on.. you know, like it is so easily done in Matlab for example). > I don't know Eclipse, but you probably have to have some top-level code in your program. As it stands, it's just an importable module, doing nothing useful when you run it. Add a call to test() to the end of the file, and it might do better. I'd also add a print statement, just to assure yourself that it's running. -- DaveA
[toc] | [prev] | [next] | [standalone]
| From | chip9munk@gmail.com |
|---|---|
| Date | 2012-11-15 05:45 -0800 |
| Message-ID | <e056d856-a9eb-44aa-a7bb-18a02993d7cb@googlegroups.com> |
| In reply to | #33380 |
On Thursday, November 15, 2012 2:42:09 PM UTC+1, Dave Angel wrote: > Add a call to test() to the end of the file, and it might do better. > > I'd also add a print statement, just to assure yourself that it's running. > > thanks, that is it, (stupid me) now if I have many functions in the model I will simply ad a call to the specific function at the end and that is it... working on the project too long, all the simple and smart ideas are long gone ;) thanks!
[toc] | [prev] | [next] | [standalone]
| From | chip9munk@gmail.com |
|---|---|
| Date | 2012-11-15 05:45 -0800 |
| Message-ID | <mailman.3715.1352987152.27098.python-list@python.org> |
| In reply to | #33380 |
On Thursday, November 15, 2012 2:42:09 PM UTC+1, Dave Angel wrote: > Add a call to test() to the end of the file, and it might do better. > > I'd also add a print statement, just to assure yourself that it's running. > > thanks, that is it, (stupid me) now if I have many functions in the model I will simply ad a call to the specific function at the end and that is it... working on the project too long, all the simple and smart ideas are long gone ;) thanks!
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2012-11-15 08:54 -0500 |
| Message-ID | <roy-F45720.08540815112012@news.panix.com> |
| In reply to | #33380 |
In article <mailman.3714.1352986928.27098.python-list@python.org>, Dave Angel <d@davea.name> wrote: > I'd also add a print statement, just to assure yourself that it's running. My trick to make sure something is running is to add "assert 0". To be fair, I usually start by adding a print statement, as Dave suggests. If I see the output, I know it ran. But if I don't see the output, there's two possibilities. Either it didn't run, or it ran but something snarfed the output and hid it from my eyes. That's common in test frameworks. It's also common in background processes where stdout goes who-knows-where, and it's anybody's guess how the logging config might be borked. On the other hand, an "assert 0" is pretty much guaranteed to produce some visible evidence that it ran. About the only thing that would stop it is if somebody had wrapped the code in a try block which caught AssertionError (or Exception).
[toc] | [prev] | [next] | [standalone]
| From | aahz@pythoncraft.com (Aahz) |
|---|---|
| Date | 2012-11-15 07:56 -0800 |
| Message-ID | <k833b1$e85$1@panix5.panix.com> |
| In reply to | #33386 |
In article <roy-F45720.08540815112012@news.panix.com>, Roy Smith <roy@panix.com> wrote: >In article <mailman.3714.1352986928.27098.python-list@python.org>, > Dave Angel <d@davea.name> wrote: >> >> I'd also add a print statement, just to assure yourself that it's running. > >My trick to make sure something is running is to add "assert 0". ``1/0`` is shorter. ;-) -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ "LL YR VWL R BLNG T S" -- www.nancybuttons.com
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-11-15 17:05 +0000 |
| Message-ID | <50a520df$0$29978$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #33391 |
On Thu, 15 Nov 2012 07:56:17 -0800, Aahz wrote: > In article <roy-F45720.08540815112012@news.panix.com>, Roy Smith > <roy@panix.com> wrote: >>In article <mailman.3714.1352986928.27098.python-list@python.org>, >> Dave Angel <d@davea.name> wrote: >>> >>> I'd also add a print statement, just to assure yourself that it's >>> running. >> >>My trick to make sure something is running is to add "assert 0". > > ``1/0`` is shorter. ;-) It is also guaranteed to run, unlike assert. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | alex23 <wuwei23@gmail.com> |
|---|---|
| Date | 2012-11-15 17:10 -0800 |
| Message-ID | <0507780b-671b-4a7d-98f7-acd5a5503a55@lg12g2000pbb.googlegroups.com> |
| In reply to | #33395 |
On Nov 16, 3:05 am, Steven D'Aprano <steve +comp.lang.pyt...@pearwood.info> wrote: > > ``1/0`` is shorter. ;-) > > It is also guaranteed to run, unlike assert. Only if they actively pass the command line switch to turn it off, which I'd assume someone intentionally using an assertion wouldn't do.
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-11-16 10:30 +0000 |
| Message-ID | <50a615c0$0$29978$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #33408 |
On Thu, 15 Nov 2012 17:10:27 -0800, alex23 wrote: > On Nov 16, 3:05 am, Steven D'Aprano <steve > +comp.lang.pyt...@pearwood.info> wrote: >> > ``1/0`` is shorter. ;-) >> >> It is also guaranteed to run, unlike assert. > > Only if they actively pass the command line switch to turn it off, Not necessarily "actively". On Linux you can set up command aliases, e.g. `alias python=python -O` and I dare say there is some equivalent under Windows. Once you have done so (which could be many months in the past, and forgotten about) you no longer need to actively specify -O to run with optimization on. > which > I'd assume someone intentionally using an assertion wouldn't do. Provided that they know the side-effect of -O, and that the code contains an assertion. Not all code is executed by the same person who wrote it, and not all people remember every fine detail about every script they wrote. I couldn't possibly tell you what all my scripts do without checking the source code. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | "Martin P. Hellwig" <martin.hellwig@gmail.com> |
|---|---|
| Date | 2012-11-15 05:44 -0800 |
| Message-ID | <cc2ae862-a957-4c98-99b8-d8f1d7516bbb@googlegroups.com> |
| In reply to | #33378 |
On Thursday, 15 November 2012 12:29:04 UTC, chip...@gmail.com wrote: > Hi all! > > > > I have a stupid problem, for which I cannot find a solution... > > > > I have a python module, lets call it debugTest.py. > > > > and it contains: > > def test(): > > a=1 > > b=2 > > c=a+b > > c > > > > so as simple as possible. > > > > Now I would like to debug it in eclipse.. (I have pydev and all) > > so the question is how do I debug the test function? (by debug I mean go into it in the debugging mode and execute step by step, inspect the variables and so on.. you know, like it is so easily done in Matlab for example). > > > > I place a break point in the function, run the debugger and it stars and is terminated immediately. (of course it does not know where to go..) > > > > So how can I do this? please help! > > > > Thank you all in advance! I assume you have at the end of the debugTest.py file something like this: if __name__ == '__main__': test()
[toc] | [prev] | [next] | [standalone]
| From | chip9munk@gmail.com |
|---|---|
| Date | 2012-11-15 05:46 -0800 |
| Message-ID | <67c7866f-3c35-4cbd-ae42-75ac5c34ce74@googlegroups.com> |
| In reply to | #33382 |
On Thursday, November 15, 2012 2:44:22 PM UTC+1, Martin P. Hellwig wrote: > I assume you have at the end of the debugTest.py file something like this: > if __name__ == '__main__': > test() no i did not have it... is main really necessary?
[toc] | [prev] | [next] | [standalone]
| From | Alister <alister.ware@ntlworld.com> |
|---|---|
| Date | 2012-11-15 14:21 +0000 |
| Message-ID | <3U6ps.201510$nB6.78865@fx21.am4> |
| In reply to | #33385 |
On Thu, 15 Nov 2012 05:46:49 -0800, chip9munk wrote: > On Thursday, November 15, 2012 2:44:22 PM UTC+1, Martin P. Hellwig > wrote: >> I assume you have at the end of the debugTest.py file something like >> this: >> if __name__ == '__main__': >> test() > > no i did not have it... > > is main really necessary? doing it that way means that it will only call test when executed directly & not when imported as a module -- I used to be an agnostic, but now I'm not so sure.
[toc] | [prev] | [next] | [standalone]
| From | chip9munk@gmail.com |
|---|---|
| Date | 2012-11-15 06:28 -0800 |
| Message-ID | <973c36bb-c554-480e-ad4a-72e3286bf539@googlegroups.com> |
| In reply to | #33388 |
On Thursday, November 15, 2012 3:21:52 PM UTC+1, Alister wrote: > doing it that way means that it will only call test when executed > directly & not when imported as a module I see, thanks!
[toc] | [prev] | [next] | [standalone]
| From | Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> |
|---|---|
| Date | 2012-11-15 14:43 +0100 |
| Message-ID | <u48fn9-s92.ln1@satorlaser.homedns.org> |
| In reply to | #33378 |
Am 15.11.2012 13:29, schrieb chip9munk@gmail.com: > I have a python module, lets call it debugTest.py. > > and it contains: > def test(): > a=1 > b=2 > c=a+b > c > > so as simple as possible. Should that be "return c" instead of "c" on a line? > Now I would like to debug it in eclipse.. (I have pydev and all) so > the question is how do I debug the test function? [...] > I place a break point in the function, run the debugger and it stars > and is terminated immediately. For a start, I would try to actually call the function. Just add "print(test())" after the function definition. Uli
[toc] | [prev] | [next] | [standalone]
| From | chip9munk@gmail.com |
|---|---|
| Date | 2012-11-15 06:27 -0800 |
| Message-ID | <93b24860-dde9-4dc6-9e75-f961b702ac1f@googlegroups.com> |
| In reply to | #33387 |
On Thursday, November 15, 2012 2:43:26 PM UTC+1, Ulrich Eckhardt wrote: > Should that be "return c" instead of "c" on a line? oh it is just a silly example function, the functionality is not important. It does not have to return anything... > For a start, I would try to actually call the function. Just add > "print(test())" after the function definition. yes I call the function now, that was the thing...
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web