Python Importing and modifying print

J. Kenney kenney at netacc.net
Wed Jan 28 07:26:07 EST 2004


Good Morning, 

Is there a way for a function called within an _imported_ 
library to call back to _calling_ python program to run a 
function? (Shown below) 

Also can you overload the print function to have it do
redirect output to an array for a bit, and then switch
it back.  (for example: right before importing make print
append each line to an array vice printing it, then going
back to normal after the import is complete.)

Many thanks!

#first_file.py
#!/usr/local/bin/python
import newlib
def main():
  print 'hi'

#newlib.py
def go():
  ???????.main()
  ???????.main()
go()

#Desired results
% ./first_file.py
hi
hi
%



More information about the Python-list mailing list