Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #42959

raw_input that able to do detect multiple input

Newsgroups comp.lang.python
Date 2013-04-06 18:03 -0700
Message-ID <cb34034e-8cd5-400b-9b71-7d365326d289@googlegroups.com> (permalink)
Subject raw_input that able to do detect multiple input
From Frank <jiewei24@gmail.com>

Show all headers | View raw


Hi all, I would require advise on this question for function call interact:

the desire outcome:
interact()
Friends File: friends.csv
Command: f John Cleese
John Cleese: Ministry of Silly Walks, 5555421, 27 October
Command: f Michael Palin
Unknown friend Michael Palin
Command: f
Invalid Command: f
Command: a Michael Palin
Invalid Command: a Michael Palin
Command: a John Cleese, Cheese Shop, 5552233, 5 May
John Cleese is already a friend
Command: a Michael Palin, Cheese Shop, 5552233, 5 May
Command: f Michael Palin
Michael Palin: Cheese Shop, 5552233, 5 May
Command: e
Saving changes...
Exiting...

my code so far for interact:
#interact function
def interact(*arg):
    open('friends.csv', 'rU')
    d = load_friends('friends.csv')
    print "Friends File: friends.csv"
    s = raw_input("Please input something: ")
    command = s.split(" ", 1)
    if "f" in command:
        display_friends("command",load_friends('friends.csv'))
        print command

#display friend function
def display_friends(name, friends_list):
Fname = name[0]
for item in friends_list:
    if item[0] == Fname:
        print item
        break
    else:
        print False

Let say if i type in " f John Cleese " and after the line 6 , my value of "command" should be ['f', 'John Cleese']. Is there ways to extract out John Cleese as a input so that i could use it on my function call "display_friends" ?

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

raw_input that able to do detect multiple input Frank <jiewei24@gmail.com> - 2013-04-06 18:03 -0700
  Re: raw_input that able to do detect multiple input Dave Angel <davea@davea.name> - 2013-04-06 21:41 -0400
    Re: raw_input that able to do detect multiple input Frank <jiewei24@gmail.com> - 2013-04-06 20:22 -0700
      Re: raw_input that able to do detect multiple input Dave Angel <davea@davea.name> - 2013-04-07 00:36 -0400
        Re: raw_input that able to do detect multiple input Frank <jiewei24@gmail.com> - 2013-04-06 22:00 -0700
          Re: raw_input that able to do detect multiple input Dave Angel <davea@davea.name> - 2013-04-07 01:25 -0400
        Re: raw_input that able to do detect multiple input Frank <jiewei24@gmail.com> - 2013-04-06 22:00 -0700
    Re: raw_input that able to do detect multiple input Frank <jiewei24@gmail.com> - 2013-04-06 20:22 -0700

csiph-web