[Tutor] On a looping input, subsequent inputs are hidden
Jim Mooney
cybervigilante at gmail.com
Wed Jun 12 20:15:56 CEST 2013
I guess that would be hard on Ben Flinkelstein ;') But I guess I could
still have give_cake = True to be more understandable.
Or keep the program the way it is, use if '' in msg , and sell it to
Guantanamo.
Jim
On 11 June 2013 19:19, Steven D'Aprano <steve at pearwood.info> wrote:
> On 12/06/13 03:53, Jim Mooney wrote:
>
> But I do like the idea of using plain old words, like "bad" as a
>> switch, instead of some inscrutable program-switch ;')
>>
>
>
> I don't. Trust me on this, you will regret it. As the Zen of Python says,
> "Explicit is better than implicit". It may seem like a good idea now, but
> some day you'll write code like this:
>
>
> def reward(msg):
> print(msg)
> if 'link' in msg:
> administer_electric_shock()
> else:
> give_cake()
>
>
> def administer_test(username):
> score = 0
> for question, answer in list_of_tests:
> response = input(question)
> if response == answer:
> score += 1
> if score > len(list_of_tests):
> msg = "Congratulations %s, you have passed!" % username
> else:
> msg = "%s, you are the weakest link!" % username
> reward(msg)
>
>
> Can you see the bug?
>
>
>
>
>
> --
> Steven
> ______________________________**_________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>
--
Jim
Today is the day that would have been tomorrow if yesterday was today
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130612/1b69e01e/attachment.html>
More information about the Tutor
mailing list