Re: [Tutor] iterators

2016-07-04 Thread eryk sun
On Mon, Jul 4, 2016 at 9:56 PM, Danny Yoo wrote: > So the extra trailing comma in a 1-tuple parenthesized expression is > just there to make it different looking, to disambiguate it from the > use of parentheses for expression grouping. The comma is the distinguishing element of non-empty tuple l

Re: [Tutor] iterators

2016-07-04 Thread Steven D'Aprano
On Tue, Jul 05, 2016 at 12:47:27AM +0100, Alan Gauld via Tutor wrote: > > I then tried using > > > > elif keycode == 27: > > > > but this statement didn't work. > > I'm not sure why that didn't work. > What exactly happened? Did you get a different error message? > If so what? I expect that t

Re: [Tutor] iterators

2016-07-04 Thread Danny Yoo
On Mon, Jul 4, 2016 at 1:38 PM, Colby Christensen wrote: > I'm sure this is something simple but I'm missing it. > When I check the statement with two values, the if statement works. However, > for the statement with one value I get an error. > keycode = event.GetKeyCode() > if keycode in (13, 37

Re: [Tutor] iterators

2016-07-04 Thread Alan Gauld via Tutor
On 04/07/16 21:38, Colby Christensen wrote: > elif keycode in (47, 392): > self.div() > elif keycode in (27): > self.clear_all() I meant to say... > I then tried using > > elif keycode == 27: > > but this statement didn't work. I'm not sure why that didn't work. What exactly happened

Re: [Tutor] iterators

2016-07-04 Thread Alex Hall
I believe the problem is what the error says: you're passing an int. When you give it two values, you're giving it a tuple, like (1, 2). That's a list type object in Python, and the 'in' keyword has to operate on lists. Therefore, it works. When you give it one value, though, you're giving it a

Re: [Tutor] iterators

2016-07-04 Thread boB Stepp
On 07/04/2016 03:38 PM, Colby Christensen wrote: I'm sure this is something simple but I'm missing it. When I check the statement with two values, the if statement works. However, for the statement with one value I get an error. keycode = event.GetKeyCode() if keycode in (13, 370): self.ent

Re: [Tutor] iterators

2016-07-04 Thread Alan Gauld via Tutor
On 04/07/16 21:38, Colby Christensen wrote: > File "/home/colby/Calculator/Calculator_betaV3.py", line 110, in OnKeyPress > elif keycode in (27): > TypeError: argument of type 'int' is not iterable The problem is that 'in' needs a collection to test. (27) is not a single element tuple but j

[Tutor] iterators

2016-07-04 Thread Colby Christensen
I'm sure this is something simple but I'm missing it. When I check the statement with two values, the if statement works. However, for the statement with one value I get an error. keycode = event.GetKeyCode() if keycode in (13, 370): self.enter() elif keycode in (43, 388): self.add() elif