best way to increment an IntVar?

Ben Finney ben+python at benfinney.id.au
Thu Jun 24 01:07:29 EDT 2010


Alan G Isaac <alan.isaac at gmail.com> writes:

> Of course one can do
> 	myintvar.set(myintvar.get()+1)
> but surely there is a better way?

What is an IntVar? It's not a built-in type, so you'll need to tell us.

    type(myintvar)

Where is it imported from?

    import sys
    sys.modules[type(myintvar).__module__]

> I'm surprsied that
> 	myintvar += 1
> is not allowed.

Does the documentation lead you to believe it would be allowed?

    help(type(myintvar))

-- 
 \       “I cannot be angry at God, in whom I do not believe.” —Simone |
  `\                                                       De Beauvoir |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list