Re: Can python quickly display results like bash?

2009-03-18 Thread robert song
thank you, it works with -m trace.

As to sh -x, it is used to expand the variables of command, and display it
before executing.

$ info bash
* The `-x' (`xtrace') option displays commands other than simple
 commands when performing an execution trace (*note The Set
 Builtin::).


2009/3/18 Chris Rebert :
> On Tue, Mar 17, 2009 at 11:13 AM, D'Arcy J.M. Cain  wrote:
>> On Tue, 17 Mar 2009 11:10:36 -0700
>> Chris Rebert  wrote:
>>> I've read the manpage for bash and can find no such -x option listed.
>>
>> It's an option from sh(1) that bash copies.  Check the man page for sh
>> (1) for a description.
>
> Ah, I should've thought to google for the sh manpage. Locally, man sh
> just gives me the bash manpage again which doesn't list -x :-(
>
> In answer to the OP's question, you can use the `trace` module
> (http://docs.python.org/library/trace.html):
>
> python -m trace -t somefile.py
>
> will display the lines of source as they are executed.
>
> Cheers,
> Chris
>
> --
> I have a blog:
> http://blog.rebertia.com
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Can python quickly display results like bash?

2009-03-17 Thread Chris Jones
On Tue, Mar 17, 2009 at 02:10:36PM EDT, Chris Rebert wrote:
> On Mon, Mar 16, 2009 at 6:05 PM, robert song  
> wrote:
> > Hello, everyone.
> > python can be debugged with pdb, but if there anyway to get a quick
> > view of the python execution.
> > Just like sh -x of bash command.
> > I didn't find that there is an option of python that can do it.
> 
> I've read the manpage for bash and can find no such -x option listed.
> And this term is nigh impossible to google for, so that didn't turn
> anything up.

Google "advanced" search -> "bash -x" - with the quotes! 

The first link displayed "bash debugging tips" has a useful discussion.

> What exactly does the -x option to bash do? Where is it documented?

$ bash -c "help set"

CJ
--
http://mail.python.org/mailman/listinfo/python-list


Re: Can python quickly display results like bash?

2009-03-17 Thread Chris Rebert
On Tue, Mar 17, 2009 at 12:15 PM, Hrvoje Niksic  wrote:
> Chris Rebert  writes:
>
>> Ah, I should've thought to google for the sh manpage. Locally, man
>> sh just gives me the bash manpage again which doesn't list -x :-(
>
> Are you sure?  On my system the OPTIONS section of bash(1) begins with:
>
>    In addition to the single-character shell options documented in
>    the description of the set builtin command, bash interprets the
>    following options when it is invoked:
> [...]
> set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
> [...]
>    -x   After expanding each simple command, for command, case
>         command, select command, or arithmetic for command, display
>         the expanded value of PS4, followed by the command and its
>         expanded arguments or associated word list.

Ah. This is what I get for using Preview to view manpages. It used
actual unicode hyphens, thus screwing up my search.

Cheers,
Chris

-- 
I have a blog:
http://blog.rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Can python quickly display results like bash?

2009-03-17 Thread Hrvoje Niksic
Chris Rebert  writes:

> Ah, I should've thought to google for the sh manpage. Locally, man
> sh just gives me the bash manpage again which doesn't list -x :-(

Are you sure?  On my system the OPTIONS section of bash(1) begins with:

In addition to the single-character shell options documented in
the description of the set builtin command, bash interprets the
following options when it is invoked:
[...]
set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
[...]
-x   After expanding each simple command, for command, case
 command, select command, or arithmetic for command, display
 the expanded value of PS4, followed by the command and its
 expanded arguments or associated word list.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Can python quickly display results like bash?

2009-03-17 Thread Chris Rebert
On Tue, Mar 17, 2009 at 11:13 AM, D'Arcy J.M. Cain  wrote:
> On Tue, 17 Mar 2009 11:10:36 -0700
> Chris Rebert  wrote:
>> I've read the manpage for bash and can find no such -x option listed.
>
> It's an option from sh(1) that bash copies.  Check the man page for sh
> (1) for a description.

Ah, I should've thought to google for the sh manpage. Locally, man sh
just gives me the bash manpage again which doesn't list -x :-(

In answer to the OP's question, you can use the `trace` module
(http://docs.python.org/library/trace.html):

python -m trace -t somefile.py

will display the lines of source as they are executed.

Cheers,
Chris

-- 
I have a blog:
http://blog.rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Can python quickly display results like bash?

2009-03-17 Thread D'Arcy J.M. Cain
On Tue, 17 Mar 2009 11:10:36 -0700
Chris Rebert  wrote:
> I've read the manpage for bash and can find no such -x option listed.

It's an option from sh(1) that bash copies.  Check the man page for sh
(1) for a description.

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Can python quickly display results like bash?

2009-03-17 Thread Chris Rebert
On Mon, Mar 16, 2009 at 6:05 PM, robert song  wrote:
> Hello, everyone.
> python can be debugged with pdb, but if there anyway to get a quick
> view of the python execution.
> Just like sh -x of bash command.
> I didn't find that there is an option of python that can do it.

I've read the manpage for bash and can find no such -x option listed.
And this term is nigh impossible to google for, so that didn't turn
anything up.
What exactly does the -x option to bash do? Where is it documented?

Cheers,
Chris

-- 
I have a blog:
http://blog.rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list