BTW do yourself a favor and learn to use the cmd module:
2 nice examples:
http://www.eskimo.com/~jet/python/examples/cmd/
it will also give you command completion if your termianl supports it
(most terminals on most linux distros do).
--
http://mail.python.org/mailman/listinfo/python-list
Well.. that put me in my place!
Fredrik Lundh - I hadn't realised that 'is' does not test for
equivalence. Thanks for the advice.
--
http://mail.python.org/mailman/listinfo/python-list
Thanks everyone for helping once again, lots of good ideas there
Thanks,
-Ivan
_
FREE pop-up blocking with the new MSN Toolbar get it now!
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
--
http://mail.python.or
(re that earlier thread, I think that everyone that thinks that it's a
good thing that certain Python constructs makes grammatical sense
in english should read the previous post carefully...)
Rob Cowie wrote:
> A string can be thought of as a tuple of characters.
footnote: the correct python ter
On Fri, 07 Oct 2005 22:21:38 -0400, Ivan Shevanski wrote:
> Yes, I realize that. . .Heres another question then. I was trying somehting
> before so that if the user just pressed enter by accident, it would not
> accept the input and ask them to put in another. But the thing is I couldnt
> get i
On Sat, 08 Oct 2005 13:19:48 +1000, Steven D'Aprano wrote:
>
> def count_matches(s, words):
> temp = [word.lower().startswith(s) for word in words]
> return len(temp)
Oops! A *serious* bug in that code :-(
Replace "return len(temp)" with "return len(filter(None, temp))".
--
Steven.
On Fri, 07 Oct 2005 22:06:31 -0400, Ivan Shevanski wrote:
> Right but see what if the user wants to type Start? I've already used the
> number menu but too many people get confused by it. . .Any other ideas?
Then let them type either the word or the number. Don't penalise your
smart users becaus
"Ivan Shevanski" <[EMAIL PROTECTED]> writes:
> Alright, I'm going to stop trying to defend my idea since it's
> obviously a bad one. What do you recommend?
Just choose the options that you present carefully. If you have
unsophisticated users and you want to be a bit fancier, put up a GUI
so they
>Is it *really* a good idea if the user types "STOP!!!" and it has the
>same effect as if they typed "Start please"?
>
>I've heard of "Do what I mean, not what I said" systems, which are usually
>a really bad idea, but this is the first time I've seen a "Do what I don't
>mean, not what I said" syst
Yes, I realize that. . .Heres another question then. I was trying somehting
before so that if the user just pressed enter by accident, it would not
accept the input and ask them to put in another. But the thing is I couldnt
get it to work. I tryed if choice1 == None it would loop and ask for a n
On Fri, 07 Oct 2005 18:03:02 -0700, [EMAIL PROTECTED] wrote:
> Why not just look at the first letter the user types instead of
> the whole string?
>
> if choice1[0] in ('1', 'S', 's'):
> #do first option
> if choice1[0] in ('2', 'E', 'e'):
> #do second option
Is it *really* a good id
"Ivan Shevanski" <[EMAIL PROTECTED]> writes:
> choice1 = raw_input("> ")
choice1 is now the whole string that the user types
> Is there a way (I searched for a module but didnt find one) that I can
> do something like this?
>
> if choice1 in ('1', 'S', 's'):
> #do first option
You'd use cho
On Fri, 07 Oct 2005 20:46:39 -0400, Ivan Shevanski wrote:
> Alright heres another noob question for everyone. Alright, say I have a
> menu like this.
>
> print "1. . .Start"
> print "2. . .End"
> choice1 = raw_input("> ")
>
> and then I had this to determine what option.
Firstly, you need to
>Perhaps a better idea is to present the user with a choice that cannot
>be deviated from, along the lines of...
>
>def main():
> print "1.\tStart"
> print "2.\tSomething Else"
> print "3.\tStop"
>
> x = raw_input()
> if x is '1': print 'Start'
> elif x is '2': print 'Something else'
>
A string can be thought of as a tuple of characters. Tuples support
membership testing thus...
choice1 = raw_input("> ")
if '1' or 's' or 'S' in choice1:
#do something
elif '2' or 'e' or E' in choice1:
#do something
It doesn't seem to me to be a good idea; If the input is 'Start',
option1 is
Ivan Shevanski wrote:
> Alright heres another noob question for everyone. Alright, say I have a
> menu like this.
>
> print "1. . .Start"
> print "2. . .End"
> choice1 = raw_input("> ")
>
> and then I had this to determine what option.
>
>
> if choice1 in ('1', 'Start', 'start'):
> #do first
Alright heres another noob question for everyone. Alright, say I have a
menu like this.
print "1. . .Start"
print "2. . .End"
choice1 = raw_input("> ")
and then I had this to determine what option.
if choice1 in ('1', 'Start', 'start'):
#do first option
if choice1 in ('2', 'End', 'end'):
17 matches
Mail list logo