[Tutor] How to inspect variables in a module from the command line

Phil Bertram phil.bertram@clear.net.nz
Fri, 27 Apr 2001 08:17:09 +1200


This is a multi-part message in MIME format.

------=_NextPart_000_0036_01C0CEF2.742197E0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi all,

I often develop my programs by writing a class in a module

class MyClass:
    stuff here

if __name__ =3D=3D '__main__' :
    klass=3DMyClass()
    klass.mutate()
    print klass.attribute

to run and test scripts written in a module. With print statements for =
debugging. (I press f5 in PythonWin).

Is there a way to switch to the interpreter and inspect the variables in =
the module
I've tried thinds like=20

>>> __main__.klass.anotherAttribute

but can't seem to work it out.

Any ideas ?

Phil B

------=_NextPart_000_0036_01C0CEF2.742197E0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR></HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hi all,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I often develop my programs by writing a class in a=20
module</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>class MyClass:</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; stuff here</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>if __name__ =3D=3D '__main__'&nbsp;:</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; klass=3DMyClass()</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; klass.mutate()</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; print =
klass.attribute</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>to run and test scripts written in a module. With =
print=20
statements for debugging. (I press f5 in PythonWin).</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Is there a way to switch to the interpreter and =
inspect the=20
variables in the module</FONT><FONT size=3D2></FONT></DIV>
<DIV><FONT size=3D2>I've tried thinds like </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>&gt;&gt;&gt; =
__main__.klass.anotherAttribute</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>but can't seem to work it out.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Any ideas ?</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Phil B</FONT></DIV></BODY></HTML>

------=_NextPart_000_0036_01C0CEF2.742197E0--