[Tutor] more problems, my final questions
Lloyd Kvam
lkvam@venix.com
Wed, 10 Jul 2002 10:36:41 -0400
I assume cont() is your old hour2 function.
In custom use cont( sleeptime). This passes the sleeptime variable to
cont. You need to change the definition of cont to something like:
def cont( sleeptime):
Now I used the same name sleeptime within both custom and cont. This isn't
necessary, but can avoid confusion. Also note that sleeptime is originally
set to be a StringType variable as returned by raw_input. You will need to
convert this to a number before doing any arithmatic with it.
sleeptime = int(sleeptime)
will do the trick so long as sleeptime is truly an integer.
You would probably be well served spending some time going through Alan Gauld's
web site:
http://www.freenetpages.co.uk/hp/alan.gauld/
Learning to program
Kyle Babich wrote:
> 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
>
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
--
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358
voice:
603-443-6155
fax:
801-459-9582