Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.03; 'typing': 0.05; 'statements,': 0.07; 'terry': 0.07; 'python': 0.07; 'initialized': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'am,': 0.14; 'wrote:': 0.14; '"invalid': 0.16; '10:': 0.16; 'editor,': 0.16; 'history.': 0.16; 'idle,': 0.16; 'reedy': 0.16; 'rerun': 0.16; 'subject:] ': 0.16; 'command': 0.19; 'jan': 0.22; 'header:In-Reply-To:1': 0.22; 'e.g.': 0.22; 'runs': 0.24; 'statement': 0.26; "i'm": 0.26; 'error': 0.29; 'hi,': 0.29; 'mode': 0.29; 'to:addr:python-list': 0.32; '(including': 0.33; 'wanting': 0.33; 'using': 0.34; 'header:X-Complaints-To:1': 0.34; 'header:User-Agent:1': 0.35; 'running': 0.36; 'rather': 0.36; 'data': 0.37; 'commands': 0.38; 'results.': 0.38; 'but': 0.38; 'used': 0.38; 'received:org': 0.38; 'to:addr:python.org': 0.39; 'header:Mime-Version:1': 0.39; 'how': 0.39; 'would': 0.40; 'header:Received:5': 0.40; 'subject:line': 0.73; "'e'": 0.84; '*simple*': 0.84; 'subject:commands': 0.84; 'want:': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: [Q] ipython: Multiple commands on the same line and newlines Date: Sat, 16 Apr 2011 12:39:55 -0400 References: <8dc6c9e4-e50e-401f-95d9-42f80a90196c@l30g2000vbn.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: rain.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 In-Reply-To: <8dc6c9e4-e50e-401f-95d9-42f80a90196c@l30g2000vbn.googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 37 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1302972019 news.xs4all.nl 41114 [::ffff:82.94.164.166]:52763 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3337 On 4/16/2011 9:55 AM, Phil Winder wrote: > Hi, > I'm having a go at using ipython as a command prompt for data > analysis. Coming from Matlab, I'm used to typing multiple commands on > the same line then using the up arrow to go through my history. > How can I write multiple python commands on the same line? You can write multiple *simple* statements using ';'. > E.g. "x = 0; while x< 10: x = x + 1;" returns an "invalid syntax" > error on the 'e' in while. All compound statements, like while, must start on own line. > Also, how can I produce a new line, without it running the command? Use an editor, as with IDLE, rather than a shell. Interactive mode runs *1* statement (including simple;simple) at a time. > would have expected a ctrl-enter or shift-enter to produce the > expected results. > E.g. I want: > "x = 0; This is one statement > while x< 10: > x = x + 1; This is another. I can understanding wanting to rerun initialized loops with one enter, but you cannot. Sorry. -- Terry Jan Reedy