[Tutor] local variables

Magnus Lycka magnus@thinkware.se
Wed, 14 Aug 2002 02:48:46 +0200


At 12:12 2002-08-13 +0200, Gregor Lingl wrote:
>My question: is there a function, an attribute, or whatever, that delivers=
 the
>fact, that x is a local variable at a point of execution where the
>assignment still hasn't taken place? Or - in other words - that delivers a=
=20
>list
>of all local variables - including those which still haven't got assigned=
=20
>a value?

 >>> y =3D 1
 >>> import inspect
 >>> def test():
...     print inspect.currentframe().f_code.co_varnames
...     x =3D y
...
 >>> test()
('x',)

But I think good unit tests is the way to find that kind of
bugs in a program.


--=20
Magnus Lyck=E5, Thinkware AB
=C4lvans v=E4g 99, SE-907 50 UME=C5
tel: 070-582 80 65, fax: 070-612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se