python shell

K

Krypto

I have been using python shell to test small parts of the big program.
What other ways can I use the shell effectively. My mentor told me
that you can virtually do anything from testing your program to
anything in the shell. Any incite would be useful.
 
T

Thorsten Kampe

* Krypto (16 May 2007 10:38:27 -0700)
I have been using python shell to test small parts of the big program.
What other ways can I use the shell effectively. My mentor told me
that you can virtually do anything from testing your program to
anything in the shell. Any incite would be useful.

use IPython
 
M

mensanator

I have been using python shell to test small parts of the big program.
What other ways can I use the shell effectively. My mentor told me
that you can virtually do anything from testing your program to
anything in the shell. Any incite would be useful.

Yeah? Well tell your mentor he can take his programs and
his literal interpretaions to the other side of the river!!

Oh...wait. Did you mean "insight"?

One thing that covers a LOT of ground is you can run other
programs from the shell and capture their output (assuming
the output is text to stdout).

For example, I can run the program factor!.exe from the
command line:

C:\python25\user>factor!.exe 27
PRIME_FACTOR 3
PRIME_FACTOR 3
PRIME_FACTOR 3

But I can also run it from the Python shell:
['PRIME_FACTOR 3\n', 'PRIME_FACTOR 3\n', 'PRIME_FACTOR
3\n']
q = [int(i.split()[1]) for i in f]
q
[3, 3, 3]

Now, you've got the factors without having to write your own
factoring program and you never had to leave the shell.

What more could you ask for?
 
J

James T. Dennis

Yeah? Well tell your mentor he can take his programs and
his literal interpretaions to the other side of the river!!
Oh...wait. Did you mean "insight"?
One thing that covers a LOT of ground is you can run other
programs from the shell and capture their output (assuming
the output is text to stdout).
For example, I can run the program factor!.exe from the
command line:
C:\python25\user>factor!.exe 27
PRIME_FACTOR 3
PRIME_FACTOR 3
PRIME_FACTOR 3
But I can also run it from the Python shell: ['PRIME_FACTOR 3\n', 'PRIME_FACTOR 3\n', 'PRIME_FACTOR
3\n']
q = [int(i.split()[1]) for i in f]
q
[3, 3, 3]
Now, you've got the factors without having to write your own
factoring program and you never had to leave the shell.
What more could you ask for?

I could ask for some tricks that would let me do things like:

* os.fork() --- but have that spawned in it's own xterm/shell
so I can no interact with each of the children separately

* Use the curses library --- with the interpreter reading from
one shell/xterm and the curses display controlling another
one.

I'm sure they're out there ... and I've love to see pointers to them.
 
S

Steve Holden

Cameron said:
.
.
.
<URL: http://en.wikipedia.org/wiki/DocTest > will probably prove more fruitful.

While I don't like follow-ups which consist of trivial corrections, I *very*
much want to encourage readers to explore Doctest more deeply; it deserves the
attention, even at the cost of appearing pedantic.

Is there some mistake in this post? I find that there *is* an article at

http://en.wikipedia.org/wiki/Doctest

but that

http://en.wikipedia.org/wiki/DocTest

doesn't refer to an extant article. Since you claim to be exercising
your pedantry, I wonder why I get the results I do. Since we *are* being
pedantic, by the way, surely the name is actually "doctest", not "Doctest".

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
------------------ Asciimercial ---------------------
Get on the web: Blog, lens and tag your way to fame!!
holdenweb.blogspot.com squidoo.com/pythonology
tagged items: del.icio.us/steve.holden/python
All these services currently offer free registration!
-------------- Thank You for Reading ----------------
 
P

Peter Anderson

Krypto said:
I have been using python shell to test small parts of the big program.
What other ways can I use the shell effectively. My mentor told me
that you can virtually do anything from testing your program to
anything in the shell. Any incite would be useful.

I'm not sure this will help - but!

I use a text editor (EditPlus under Windows) as a mini IDE. Some text
editors have a concept of "tools" where you can run the "tool" from
within the editor and it calls an external program to run the source
code in the editor. With EditPlus the tool looks something like:

Menu text: Python
Command: C:\Python25\python.exe
Argument: "$(FileName)"
Initial directory: $(FileDir)
Capture output: [X]

Output from the program run is captured in an "output window". A full
blown IDE it ain't but handy it is.

Regards,
Peter
--
Peter Anderson

There is nothing more difficult to take in hand, more perilous to
conduct, or more uncertain in its success, than to take the lead in the
introduction of a new order of things &mdash; Niccolo Machiavelli, "The
Prince", ch. 6
 
D

Douglas Woodrow

Since you claim to be exercising your pedantry, I wonder why I get the
results I do. Since we *are* being pedantic, by the way, surely the
name is actually "doctest", not "Doctest".

Yes, as the page you are referring to mentions right at the top:

,----------------
| Doctest
| From Wikipedia, the free encyclopedia
|
| The correct title of this article is doctest. The initial letter
is shown
| capitalized due to technical restrictions.
`----------------
 
P

Paddy

.
.
.
<URL:http://en.wikipedia.org/wiki/DocTest> will probably prove more fruitful.

While I don't like follow-ups which consist of trivial corrections, I *very*
much want to encourage readers to explore Doctest more deeply; it deserves the
attention, even at the cost of appearing pedantic.

Sometimes you have to mess with the case of letters in wiki pages
which is the case here, but I did actually cut-n-paste the address
from Wikipedia as I like to look at the page from time to time as,
like yourself, I think doctest shows the true spirit of what is
Pythonic, and created the page when I found Wikipedia did not have it.

Gets me thinking along the lines of "What else should the intermediate
Python programmer know about"?


The other Python tool I am apt to carp on about is Kodos
http://kodos.sourceforge.net/ .
Kodos is a great tool for those new to reguar expressions. It allows
you to test your regular expressions on snippets of text and gives
great visual feedback on the results. After over a decade of writing
regexps I still use Kodos occasionally, and wish I had such a tool a
decade ago.

- Paddy.
 
S

Steve Holden

Douglas said:
Yes, as the page you are referring to mentions right at the top:

,----------------
| Doctest
| From Wikipedia, the free encyclopedia
|
| The correct title of this article is doctest. The initial letter
is shown
| capitalized due to technical restrictions.
`----------------
Whereas Cameron wrote
> ... to explore Doctest more deeply ...

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
------------------ Asciimercial ---------------------
Get on the web: Blog, lens and tag your way to fame!!
holdenweb.blogspot.com squidoo.com/pythonology
tagged items: del.icio.us/steve.holden/python
All these services currently offer free registration!
-------------- Thank You for Reading ----------------
 
J

JussiJ

My mentor told me that you can virtually do anything from
testing your program to anything in the shell. Any incite
would be useful.

Using something like tee you can run the Python script in
the shell and also capture it's output:

http://unxutils.sourceforge.net/

For example, here are details on how to use tee within
the Zeus IDE:

http://www.zeusedit.com/forum/viewtopic.php?t=74

Jussi Jumppanen
Author: Zeus for Windows IDE
http://www.zeusedit.com - Zeus for Windows Programmer's IDE
 
C

Cameron Laird

.
.
.
Sometimes you have to mess with the case of letters in wiki pages
which is the case here, but I did actually cut-n-paste the address
from Wikipedia as I like to look at the page from time to time as,
like yourself, I think doctest shows the true spirit of what is
Pythonic, and created the page when I found Wikipedia did not have it.
So *you* were the one! Nice work--that is, I think
we agree (despite my erratic spelling) that doctest
deserves plenty of attention, and a Wiki page is a
nice place to collect miscellaneous details.
.
.
.
The other Python tool I am apt to carp on about is Kodos
http://kodos.sourceforge.net/ .
Kodos is a great tool for those new to reguar expressions. It allows
you to test your regular expressions on snippets of text and gives
great visual feedback on the results. After over a decade of writing
regexps I still use Kodos occasionally, and wish I had such a tool a
decade ago.
Thanks for the tip. You might have an interest in
<URL: http://regularexpressions.com/#what_is_is >.
.
.
.
I've sent copies of this follow-up both to Paddy and,
on the chance that the URL will serve others, to
comp.lang.python.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,292
Messages
2,571,494
Members
48,183
Latest member
GarfieldBa

Latest Threads

Top