Re: [Tutor] Local vs global

2009-11-08 Thread bibi midi
On Sun, Nov 8, 2009 at 8:38 AM, Dave Angel wrote: > > You have the following line at top-level: > > if ask.lower not in reply: > > But you're not calling the method str.lower(), you're just creating a > function object from it. You need those parentheses. > > if ask.lower() not in reply: > >

Re: [Tutor] Local vs global

2009-11-08 Thread Lie Ryan
bibi midi wrote: On Sun, Nov 8, 2009 at 6:20 AM, bibi midi > wrote: Thank you all for the helpful insights. I will keep in mind the naming rules in Python, so as not to have it in collision with Python's builtins. The mention to tidy up e.g. "co

Re: [Tutor] Local vs global

2009-11-08 Thread ALAN GAULD
> Remember, that unlike Pascal, in Python you don't call the > function unless you include the parentheses. And since you are unlikely to be old enough to have programmed in Pascal(!), I'll add unlike VB you don't call the function unless you include parentheses. :-) Alan G.

Re: [Tutor] Local vs global

2009-11-08 Thread Dave Angel
bibi midi wrote: On Sun, Nov 8, 2009 at 6:20 AM, bibi midi wrote: Thank you all for the helpful insights. I will keep in mind the naming rules in Python, so as not to have it in collision with Python's builtins. The mention to tidy up e.g. "compartmentalize" code is also noted. I agree de

Re: [Tutor] Local vs global

2009-11-08 Thread Eri Mendz
On Sat, Nov 7, 2009 at 3:26 PM, Dave Angel wrote: > Alan Gauld wrote: >> > Alan - Excellent comments, as usual. > > bibimidi - I would point out that after you remove the 'global choose' line > as Alan said, you should rename the global variable you're using to store > the return value.  They're a

Re: [Tutor] Local vs global

2009-11-08 Thread bibi midi
On Sun, Nov 8, 2009 at 6:20 AM, bibi midi wrote: > Thank you all for the helpful insights. I will keep in mind the naming > rules in Python, so as not to have it in collision with Python's > builtins. > > The mention to tidy up e.g. "compartmentalize" code is also noted. I > agree definitely. >

Re: [Tutor] Local vs global

2009-11-07 Thread bibi midi
On Sat, Nov 7, 2009 at 3:26 PM, Dave Angel wrote: > Alan Gauld wrote: >> > Alan - Excellent comments, as usual. > > bibimidi - I would point out that after you remove the 'global choose' line > as Alan said, you should rename the global variable you're using to store > the return value. They're a

Re: [Tutor] Local vs global

2009-11-07 Thread Dave Angel
Alan Gauld wrote: "bibi midi" wrote in Although i have read up quite a lot about local and global scope in functions i still 'suffer' understanding it, ... I tried removing it but i get error variable undeclared or something. It is in the function choose_Cave. We need to see the exact erro

Re: [Tutor] Local vs global

2009-11-07 Thread Alan Gauld
"bibi midi" wrote in Although i have read up quite a lot about local and global scope in functions i still 'suffer' understanding it, ... I tried removing it but i get error variable undeclared or something. It is in the function choose_Cave. We need to see the exact error text, the whole