Re: [Tutor] Local vs global
by Bibi Midi other posts by this author
Nov 8 2009 2:20AM messages near this date
Re: [Tutor] Local vs global
|
Re: [Tutor] Local vs global
On Sun, Nov 8, 2009 at 6:20 AM, bibi midi <bibsmendez@[...].com> 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.
>
> I'm reworking my code and will post back.
>
For reason unknown to me the script dont repeat itself
when asked if to play again or not no matter what juggling of the
while/if conditionals i do, the result is the same. What am i
missing?
Also, I'm not sure I'm right in the assignment ans = choose_Cave.
I code it like so because the assignment ans = choose_Cave()
the prompt 'Choose a cave' is repeated when the script is run.
Dont want this. I tested this when run in ipython.
I dont know if there is a way to just retrieve the return value to a
variable AND not run the whole function i mean in the case of
ans = choose_Cave(). Would love to hear your expert insights by return.
http://paste.debian.net/51004/
--
Best Regards,
bibimidi
On Sat, Nov 7, 2009 at 3:26 PM, Dave Angel <davea@[...].org> 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 allowed to have the same name, but it's
confusing
> to a beginner if they do, since you might assume they somehow share the
> value.
>
Thread:
Bibi Midi
Alan Gauld
Bibi Midi
Bibi Midi
Bibi Midi
Lie Ryan
Dave Angel
Alan Gauld
Dave Angel
Eri Mendz
|