Thank you Gabriel! Malcolm
----- Original message ----- From: "Gabriel Genellina" <gagsl-...@yahoo.com.ar> To: python-list@python.org Date: Wed, 11 Feb 2009 02:04:47 -0200 Subject: Re: Difference between vars() and locals() and use case for vars() En Wed, 11 Feb 2009 01:38:49 -0200, <pyt...@bdurham.com> escribió: > Can someone explain the difference between vars() and locals()? > I'm also trying to figure out what the use case is for vars(), > eg. when does it make sense to use vars() in a program? Without arguments, vars() returns the current namespace -- same as locals() inside a function, same as locals() *and* globals() outside any function (i.e., in a module or running in the interactive interpreter) With an argument (that is, vars(x)) it returns the names defined by the object itself; for "normal" class instances, that means its __dict__ It's useful in the interactive interpreter, to examine some object's contents. Maybe in other special cases. Certainly not in everyday's programming. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list