Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77794
| References | <ce20cc54-7632-4928-a061-455d1bc11467@googlegroups.com> |
|---|---|
| Date | 2014-09-12 15:26 +1000 |
| Subject | Re: Why command os.popen works in python interactive mode but not in script debugger mode? |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13957.1410499567.18130.python-list@python.org> (permalink) |
On Fri, Sep 12, 2014 at 3:15 PM, Viet Nguyen
<vhnguyenn@yahoo.com.dmarc.invalid> wrote:
> But from debugger mode in a script:
>>>> import os
> (Pdb) p = os.popen('date')
> *** SyntaxError: SyntaxError('invalid syntax', ('<string>', 1, 1, "= 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’t recognize are assumed to be Python
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 = os.popen('date')
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why command os.popen works in python interactive mode but not in script debugger mode? Viet Nguyen <vhnguyenn@yahoo.com> - 2014-09-11 22:15 -0700 Re: Why command os.popen works in python interactive mode but not in script debugger mode? Chris Angelico <rosuav@gmail.com> - 2014-09-12 15:26 +1000 Re: Why command os.popen works in python interactive mode but not in script debugger mode? Viet Nguyen <vhnguyenn@yahoo.com> - 2014-09-12 06:39 -0700
csiph-web