Question:Programming a game grid ...

woooee at gmail.com woooee at gmail.com
Wed Jun 27 22:15:54 EDT 2012


On Wednesday, June 27, 2012 5:15:09 PM UTC-7, Steven D'Aprano wrote:
> On Wed, 27 Jun 2012 16:24:30 -0700, David wrote:
> 
> > First, you should be getting an error on 
> > vars()[var] = Button(f3, text = "00", bg = "white")
> > as vars() has not been declared
> 
> The Fine Manual says differently:
> 
> Python 2:
> http://docs.python.org/library/functions.html#vars
> 
> Python 3:
> http://docs.python.org/py3k/library/functions.html#vars
> 
> 
> > and it does not appear to be valid Python syntax.
> 
> It's perfectly fine syntax, no different from:
> 
> my_dict['spam'] = 'a yummy ham-like substance'
> 
> or similar.
> 
> 
> -- 
> Steven

"as vars() has not been declared and it does not appear to be valid Python syntax"

You assume too much IMHO.  Vars() was not declared in the code provided and I do not think that we should be assuming that it is a function returning a dictionary instead of an error.  Just my opinion.



More information about the Python-list mailing list