Re: [Tutor] Problem with if statements and else statements

2017-05-30 Thread Cameron Simpson
On 30May2017 12:06, Peter Otten <__pete...@web.de> wrote: Cameron Simpson wrote: As written it should be a bit slower: to construct a set each member get tested for presence. The cost is in making the set, not in searching it. No, CPython is a bit smarter than that: dis.dis('if m in {"1", "J

Re: [Tutor] Problem with if statements and else statements

2017-05-30 Thread Peter Otten
Cameron Simpson wrote: > On 29May2017 01:17, Alan Gauld wrote: >>On 29/05/17 00:12, Alex Kleider wrote: >>> Would >> if Month in {'January', '1'}: >>> >>> be even better? (regarding efficiency perhaps? Trivial point, I know, >>> but just wondering.) >> >>If in doubt try it out and profile/ti

Re: [Tutor] Problem with if statements and else statements

2017-05-29 Thread Alex Kleider
On 2017-05-29 16:08, Cameron Simpson wrote: snip BTW, in Python we tend to use named like "Fred" for classes (or factories), and "fred" for regular variables. And "FRED" for things that would be constants in other languages. Eg: MAX_THINGS = 16 class Foo: def FooBah(x): return

Re: [Tutor] Problem with if statements and else statements

2017-05-29 Thread Cameron Simpson
On 29May2017 01:17, Alan Gauld wrote: On 29/05/17 00:12, Alex Kleider wrote: Would if Month in {'January', '1'}: be even better? (regarding efficiency perhaps? Trivial point, I know, but just wondering.) If in doubt try it out and profile/time it. But I don't think it will make much diff

Re: [Tutor] Problem with if statements and else statements

2017-05-28 Thread Peter Otten
Alex Kleider wrote: > On 2017-05-28 13:13, Mats Wichmann wrote: > >> FWIW, if checking for multiples, you could also write: >> >> if Month in ['January', '1']: > > Would > if Month in {'January', '1'}: > > be even better? (regarding efficiency perhaps? Trivial point, I know, > but just

Re: [Tutor] Problem with if statements and else statements

2017-05-28 Thread Alan Gauld via Tutor
On 29/05/17 00:12, Alex Kleider wrote: > On 2017-05-28 13:13, Mats Wichmann wrote: > >> FWIW, if checking for multiples, you could also write: >> >> if Month in ['January', '1']: > > Would > if Month in {'January', '1'}: > > be even better? (regarding efficiency perhaps? Trivial point, I

Re: [Tutor] Problem with if statements and else statements

2017-05-28 Thread Alex Kleider
On 2017-05-28 13:13, Mats Wichmann wrote: FWIW, if checking for multiples, you could also write: if Month in ['January', '1']: Would if Month in {'January', '1'}: be even better? (regarding efficiency perhaps? Trivial point, I know, but just wondering.)

Re: [Tutor] Problem with if statements and else statements

2017-05-28 Thread Mats Wichmann
On 05/27/2017 06:14 PM, boB Stepp wrote: > Hello Jalen! > > On Sat, May 27, 2017 at 4:19 PM, Jalen Barr wrote: >> >> In this code it always changes the PlaceHolder to 0 no matter what Month is >> set to >> >> Month ="September" >> >> if Month == "January" or "1": >> PlaceHolder = 0 > > This

Re: [Tutor] Problem with if statements and else statements

2017-05-27 Thread boB Stepp
Hello Jalen! On Sat, May 27, 2017 at 4:19 PM, Jalen Barr wrote: > > In this code it always changes the PlaceHolder to 0 no matter what Month is > set to > > Month ="September" > > if Month == "January" or "1": > PlaceHolder = 0 This must be written as: if Month == "January" or Month == "1":

Re: [Tutor] Problem with if statements and else statements

2017-05-27 Thread Jalen Barr
I am in Python version 3.6.1 On Sat, May 27, 2017 at 4:19 PM, Jalen Barr wrote: > In this code it always changes the PlaceHolder to 0 no matter what Month > is set to > > Month ="September" > > if Month == "January" or "1": > PlaceHolder = 0 > else: > print("Information Error") > print(P

[Tutor] Problem with if statements and else statements

2017-05-27 Thread Jalen Barr
In this code it always changes the PlaceHolder to 0 no matter what Month is set to Month ="September" if Month == "January" or "1": PlaceHolder = 0 else: print("Information Error") print(PlaceHolder) ___ Tutor maillist - Tutor@python.org To un