[Tutor] more problems, my final questions

Kyle Babich Kyle Babich" <kb@kb5.org
Wed, 10 Jul 2002 13:27:44 +0000


It works! :)

The only bug I have left is when trying to execute cont() I need the
sleeptime variable from custom().  How do I import it?

On Tue, 9 Jul 2002 22:35:49 -0400, "Timothy M. Brauch"
<tbrauch@mindless.com> said:
> ----- Original Message -----
> From: "Kyle Babich" <kb@kb5.org>
> To: "tutor" <tutor@python.org>
> Sent: Tuesday, July 09, 2002 10:08 PM
> Subject: [Tutor] more problems, my final questions
> 
> 
> > New problems has arisin.  I was wondering if there was way to replace:
> > if begin in "Yy":
> >         print "why is the sky blue?"
> >
> > With something like:
> > if begin == "Y" "y":
> >         print "why isn't the sky green or purple?"
> 
> You should be able to use either:
> if begin in ['Y', 'y']:
>         do something
>         ...
> or
> if begin == 'Y' or begin == 'y':
>         do something
>         ...
> 
> I am not sure which one is preferred...
> > (only unlike the code above I need something that works of course)
> >
> > I'm asking because I recently added:
> > else begin in "CustomcustomCUSTOM":
> 
> In this case, I think it would be better to use the list:
> if begin in ['Custom', 'custom', 'CUSTOM']:
>         ...
> 
> > But I had also changed the Yy and Nn to be YyYesyesYES and NnNonoNO,
> > however the o in No and the o and custom are conflicting and I'm trying
> > to find a way to fix this.  Any ideas?
> 
> Although, a solution I just thought of that might make things even
> easier...
> import string
> ...
> begin = string.lower(begin)
> if begin in ['y', 'yes']:
>         ...
> 
> The third line converts begin to all lowercase (you could just as
> arbitrarily use string.upper()) thus making the possible choices fewer.
> 
> Although, all of this is fly-by-the-seat-of-my-pants-untested code.  It
> looks correct as I type it into my email...
> 
> > Also, my final questions regaurding this program:
> > Could some one point me to an example or show me how to
> > countdown/countup time.sleep?
> > And the same goes for delaying/suspending and prematurly ending
> > time.sleep.
> 
> Someone else will have to handle this.  I will admit I only listen to
> this
> list with one ear, that is, only when I have free time, which seems to
> be
> almost never.
> 
> > If anyone sees any problems-waiting-to-happen in my program (attached)
> > please tell me.
> 
> Again, someone else...
> 
> > Thank you, this list has been so helpful.
> > --
> > Kyle
> 
>  - Tim
> 
> 
> 
> 
> 

--
Kyle