Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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:not': 0.03; 'syntax': 0.04; '"""': 0.07; 'context': 0.07; 'assumed': 0.09; 'debugger': 0.09; 'executed': 0.09; 'here?': 0.09; 'statements': 0.09; 'subject:Why': 0.09; 'subject:command': 0.09; 'subject:script': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; "('',": 0.16; '(pdb)': 0.16; 'debugger.': 0.16; 'exclamation': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'prefixed': 0.16; 'subject: \n ': 0.16; 'syntaxerror:': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'command': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'recognize': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In- Reply-To:1': 0.27; 'point': 0.28; 'mode': 0.30; 'message- id:@mail.gmail.com': 0.30; '>>>>': 0.31; 'prints': 0.31; 'sep': 0.31; 'anyone': 0.31; 'url:python': 0.33; 'fri,': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'subject:?': 0.36; 'url:org': 0.36; 'being': 0.38; 'skip:o 20': 0.38; 'url:library': 0.38; 'pm,': 0.38; '12,': 0.39; 'commands': 0.60; 'nguyen': 0.84; 'to:none': 0.92; '***': 0.95 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=WUqJt1wGDm3xCHQnSmJnrb9PQjfXu4QtPqaOo1eUc4M=; b=OlGkUuVGLHdK5Ljhb1Gw9b6hdD7WznyA1xeNsVWKea/G/aUOcJhQpX/wVhSUM4eqD2 ARDhiuz6nX8CQ2FksPEnwSf6+Cfd+CCQmPJGUObe/ic5Dsp7ffM+40Ksa7suTxRKhdbb mTCp958FJql+Rin4vUmHKnQMNcAZJQFYeSDTB3NyDaJgrh6XzGVFSnWrzP3nB3MygfGF l/ZIAJ9WvxrZ4wVnpMPO1yKg0oOLWa4PkgkvRJKwOpCkmqDYafL+KTXUqyPhfmpwxWqb 4eY05gxD2UcnfAi+HdsavD25evMkem9KdKJIuenTUkeCt7dTPDH7iF6JbXNi4O39vLVR jtbA== MIME-Version: 1.0 X-Received: by 10.50.176.202 with SMTP id ck10mr14088240igc.2.1410499564776; Thu, 11 Sep 2014 22:26:04 -0700 (PDT) In-Reply-To: References: Date: Fri, 12 Sep 2014 15:26:04 +1000 Subject: Re: Why command os.popen works in python interactive mode but not in script debugger mode? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1410499567 news.xs4all.nl 2861 [2001:888:2000:d::a6]:55100 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:77794 On Fri, Sep 12, 2014 at 3:15 PM, Viet Nguyen wrote: > But from debugger mode in a script: >>>> import os > (Pdb) p =3D os.popen('date') > *** SyntaxError: SyntaxError('invalid syntax', ('', 1, 1, "=3D os= .popen('date')")) > > > Can anyone help me why there is syntax here? > This is actually a command to the debugger. You say "p some_expression" and it prints out the value of some_expression. https://docs.python.org/2/library/pdb.html#debugger-commands """" Commands that the debugger doesn=E2=80=99t recognize are assumed to be Pyth= on statements and are executed in the context of the program being debugged. Python statements can also be prefixed with an exclamation point (!). """ So try this: !p =3D os.popen('date') ChrisA