[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > On May 16, 12:38 pm, Krypto <[EMAIL PROTECTED]> wrote: >> 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: >>>> import os >>>> f = os.popen("factor! 27").readlines() >>>> f > ['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. -- Jim Dennis, Starshine: Signed, Sealed, Delivered -- http://mail.python.org/mailman/listinfo/python-list