Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'value,': 0.04; 'argument': 0.05; 'output': 0.05; 'friend.': 0.07; 'rename': 0.07; 'arguments': 0.09; 'assumed': 0.09; 'window.': 0.09; "wouldn't": 0.14; '"f"': 0.16; 'be:': 0.16; 'code?': 0.16; 'command,': 0.16; 'command:': 0.16; 'filename.': 0.16; 'inserting': 0.16; 'list"': 0.16; 'may"': 0.16; 'quoted': 0.16; 'responses.': 0.16; 'silly': 0.16; 'top-level': 0.16; 'tut': 0.16; 'user?': 0.16; '(you': 0.16; 'fix': 0.17; 'wrote:': 0.18; '-the': 0.19; 'pointed': 0.19; 'command': 0.22; 'code,': 0.22; 'input': 0.22; 'example': 0.22; 'separate': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'adds': 0.24; 'initial': 0.24; 'file.': 0.24; 'environment': 0.24; 'question': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'michael': 0.29; 'am,': 0.29; 'forgot': 0.30; "i'm": 0.30; 'code': 0.31; 'comments': 0.31; 'apparently': 0.31; 'file:': 0.31; 'subject:that': 0.31; 'this.': 0.32; 'front': 0.32; 'stuff': 0.32; 'interface': 0.32; 'run': 0.32; 'says': 0.33; 'not.': 0.33; 'no,': 0.35; 'but': 0.35; 'add': 0.35; 'there': 0.35; 'described': 0.36; 'idle': 0.36; 'interaction': 0.36; 'next': 0.36; 'should': 0.36; 'wrong': 0.37; 'clear': 0.37; 'expected': 0.38; 'ends': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'new': 0.61; 'john': 0.61; "you're": 0.61; 'times': 0.62; "you've": 0.63; 'information': 0.63; 'name': 0.63; 'skip:n 10': 0.64; 'different': 0.65; 'here': 0.66; 'frank': 0.68; 'invalid': 0.68; 'prompt': 0.68; 'received:74.208': 0.68; 'saving': 0.69; 'friend': 0.79; 'friends': 0.81; "'result'": 0.84; 'different.': 0.84; 'end-user': 0.84; 'nes': 0.84; 'palin': 0.84; 'received:74.208.4.194': 0.84; 'shop,': 0.84; 'updated,': 0.84; 'ministry': 0.91 Date: Sun, 07 Apr 2013 01:25:47 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: python-list@python.org Subject: Re: raw_input that able to do detect multiple input References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:WWs90xvf1+f/HDeL5YnQegq4UJYr4HFTyW8em13GhL6 mORqSXseC0nR5phst47QWwVJkCCZ4xg5LfjiFNOupr5k29yaPa SqTeb6NXO5lR/0dgu1u63EIjc1AATbJfksxdjpk8Ygb/tB1tRa vDAr+scb1GyBwO9R8BQWdJLkuzcbFAkO1/uFTf7qhI4zsWWnjH HVVR81ow+LV2D9P6uroP9vnfY1R8wNAgPeuH9w3ID4wJcsLGR6 E9A71LoheO3te9r+mIMbWh8n+lwUqIIKMK/ev80QZemvAXWFNj J33h5KmHLvjVq7cGSDU4KLacC5P8Ys4It9deTquYzvgWbDMBg= = X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 89 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365312366 news.xs4all.nl 6906 [2001:888:2000:d::a6]:44570 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:42979 (You forgot to separate the parts of my comments that you were quoting from your responses. Any decent email program will do that for you automatically, inserting "< " in front of each quoted line. Then you just hit enter a couple of times to type the new stuff right after the part you're quoting.) On 04/07/2013 01:00 AM, Frank wrote: > Now you've saved the data in a different file. How does the next run of > the program find it? > > > What user? In what environment can a user enter function calls into > your code? > -The user will call the function out from IDLE So the user is the programmer. No end-user would be using IDLE to run a program. > > Why is the command invalid? > -Because the user need to type out a name after the "f" But that wouldn't be an invalid command, but invalid data > > That's not the way the message is worded in the code > - because if user type in " a John Cleese, Cheese Shop, 5552233, 5 May" > it mean it would takes four arguments (comma separated) with information > about a person and adds that person to my "friends.csv". An error message is printed if that person is already a friend. Because the name "John Cleese" is already in my friends.csv that why it will prompt out "John Cleese is already a friend" So fix the code, I just pointed out that the message was different. The code says print "%s is already in the list" % name Yet you say the message needs to be: > John Cleese is already a friend One or the other is incorrect. > > In this function and in save_friends, there is no return value, so not > clear what you mean by 'result' > > e ends the interaction and, if the friends information has been > updated, the information is saved to the friends.csv , i think i used the wrong function for this. No, just the wrong filename. I assumed you were going to rename it afterwards, tut apparently not. > > The question I'm told to work on: > interact() is the top-level function that de nes the text-base user interface > as described in the introduction. > So if you call interact() in your program at the top-level, then a non-programmer can run the program directly from the terminal window. > Here is an example of what is expected from your program. The input is > everything after Command: on a line (and the initial friends.csv). Every- > thing else is output. Your output should be exactly the same as below for > the given input. > > 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... > You will also need to add an argument to the raw_input() to have it produce the output specified. -- DaveA