Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52506 > unrolled thread

Re: Verifying Variable value

Started byKrishnan Shankar <i.am.songoku@gmail.com>
First post2013-08-14 04:29 -0700
Last post2013-08-14 04:29 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Verifying Variable value Krishnan Shankar <i.am.songoku@gmail.com> - 2013-08-14 04:29 -0700

#52506 — Re: Verifying Variable value

FromKrishnan Shankar <i.am.songoku@gmail.com>
Date2013-08-14 04:29 -0700
SubjectRe: Verifying Variable value
Message-ID<mailman.569.1376479751.1251.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

Hi Chandan,

Python has built-in module called pdb which can be used for debugging.
Importing it in the right place will be like setting break point in code
and will change the execution to debugging mode. We can use different
debugging commands ((n)ext, (c)ontinue, (s)tep  etc) to evaluate through
the code. Below is the link to module,

http://docs.python.org/2/library/pdb.html

We can run this code in the following way "python -m pdb filename.py" to
run it in pdb debugging mode. Else import pdb and set the trace at right
place like below.

For example
=========
def method()
  import pdb;pdb.set_trace()   <<<----------  import and set_trace()
  a = 20
  b =30
  c =  a + b

method()

While running you will get pdb prompt to debug the code line by line. The
execution will be in user's hands.  Like below,

> c:\users\krishnan\desktop\test.py(3)method()
-> a = 20
(Pdb) n
> c:\users\krishnan\desktop\test.py(4)method()
-> b =30
(Pdb) n
> c:\users\krishnan\desktop\test.py(5)method()
-> c =  a + b
(Pdb) n
--Return--
> c:\users\krishnan\desktop\test.py(5)method()->None
-> c =  a + b
(Pdb) c

You can explore the module and find it useful for debugging. I hope this
helps

Regards,
Krishnan


On Wed, Aug 14, 2013 at 3:12 AM, chandan kumar <chandan_psr@yahoo.co.in>
wrote:
Hi ,

Is there a way to validate variable values while debugging any python
code.Run below example  in debugging mode and i would like to know the
value of c (I know print is an option) with any other option other than
printing.
In C# or some other tools we can verify each statement and values. Is there
way to check each statement in python code like in c#.

Ex:
def method()
  a = 20
  b =30
  c =  a + b


Best Regards,
Chanadn

--
http://mail.python.org/mailman/listinfo/python-list

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web