[Tutor] printing out the definition of a func

lonetwin lonetwin@yahoo.com
Fri, 21 Dec 2001 13:39:58 +0530

Hi there, Llyod, Alan, Blake, (and a note for everybody else futher down)
     Thanx for replying,

On Thursday 20 December 2001 19:26, Llyod wrote:
> I am pretty sure that you are asking too much.
     I thought as much <sigh>

>  Even in text mode,
> you should be able to switch between different sessions.  Keep one
> session in your editor window where the source file is visible.
> Then have a Python session.  Use:
> import FILENAME		- the first time
> reload(FILENAME)
> - later times
> to get the latest changes from the source file.  Rember to save to
> the disk from your editor.
     That's how I do it .....but it's such a pain, 'cos I keep forgetting to 
save, or to reload.....or I just end up def-ing a function/class in the 
intepreter itself, before I realise it just got too long :)

Alan wrote:
> Maybe emacs -nw would be your best bet - then you can split the 
> screen in text mode, run a shell in one pane(running python) 
> and edit the code in the other pane. However emacs may be 
> as big a resource hog as X....
      Emacs ......who that ??? .......me vi  guy :)

Blake wrote:
> or screen...
> http://www.math.fu-berlin.de/~guckes/screen/
     Hey thanx....I didn't know about screen, it was already there on my 
system......looks useful :)

Thanx all

Ok, now everything beyond this is purely fun value....I might never use 
something like this actually.......but here goes (pssst Danny I think you 
like games .......even if they are totally pointless :)
 ......here goes, now this is utterly stupid, but since I was so taken up by 
this problem .....I started writing some crap,  I thought I'd write a wrapper 
around the python intepreter (call it wrappy.py) and use that instead ....the 
idea is, I fire up the intepreter as a sub process to my program, connect the 
stdin/stdout to the sub-process, with the stdin/stdout of my program, and 
monitor everything that goes thru' the stdin, as soon as I see a def or a 
class keyword, I start saving up the strings in a dict with the 
func-name/class-name as key. And when I see another keyword
 (say "showCode argument") I recall and print the string that was saved with 
"argument" as key. I don't know if I'm clear enough ??!! (tell me if I'm not)

     I tried using a os.popen[2/3] but didn't seem to get anywhere, I don't 
really know how os.pipe() works, but maybe that should serve my purpose ...I 
don't know !!!....an' I won't get sleep untill I get it working (then 
ofcourse I'll throw it away :)) ......
......I think I need professional help :). If anyone could help me 
out....please do 


I get up each morning, gather my wits.
Pick up the paper, read the obits.
If I'm not there I know I'm not dead.
So I eat a good breakfast and go back to bed.

Oh, how do I know my youth is all spent?
My get-up-and-go has got-up-and-went.
But in spite of it all, I'm able to grin,
And think of the places my get-up has been.
                -- Pete Seeger