### #-------------------------- def isInteractive(): """Returns 1 if we're running in an interpreter window, and false otherwise. This is a variation of what pydoc.help() tries. If it doesn't work it might be because the None, 1, "?" is occuring on a different line. One might consider the following approach instead:
for li in inspect.stack(): if li[1:4] == (None, 1, "?"): return 1
"""
#return inspect.stack()[2][1:4] == (None, 1, "?")
# the line above will enable the math if called on the 1st line of a script
#return inspect.stack()[3][1].find("PyInteractive")<>0
# but if this encounters a None at that position it will not be able
# to use the find function. SO...let's just look through the whole stack
import inspect
return str([x[1] for x in inspect.stack()]).find("PyInteractive")>-1
#-------------------------- def cls(): """A function to clear the output window.""" import sys,os if sys.platform in ['mac', 'darwin']: if isInteractive(): import PyConsole PyConsole.console.clearbuffer() print else: print #in case the window is not open yet sys.stdout.clearbuffer() else: try: os.system('cls') except: try: os.system('clear') except: try: print sys.stdout.write(os.popen("clear").read()) except: print '\n'*80 ###
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor