Verifying Variable value

Dave Angel davea at davea.name
Wed Aug 14 08:01:58 EDT 2013


chandan kumar 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

I haven't used the language called C# since before it was renamed.  But
if they were at all consistent to its forbears, you must be talking
about assert().

assert() works pretty much the same in Python, though you don't need the
parens.

    assert c==50

will throw an AssertionError if c is unequal to 50


>   <SNIP>
> <html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div>Hi ,</div><div><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;">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.</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; background-color: 

Can you please just post via text mail, rather than having superfluous
html which isn't displayable for most users?  Most of the time when
posted code loses indentation, it's the fault of mis-shapen html.

-- 
DaveA




More information about the Python-list mailing list