Re: Print statement isn't showing up?

2008-08-06 Thread Lie
On Aug 6, 2:28 am, Timothy Grant [EMAIL PROTECTED] wrote:
 On Tue, Aug 5, 2008 at 9:09 AM, Robert Dailey [EMAIL PROTECTED] wrote:
  Hi,

  I have the following code:

  def ReplaceExternalWithCopy( localDir, remoteDir ):
      print Removing external local directory:, localDir
      rmdirs( localDir )
      vfxrepo.copy( remoteDir, localDir )

  I noticed that the print statement above does not show up before
  vfxrepo.copy() is called. the copy() function (as well as the rmdirs()
  function) are very long file-system calls that take up to 5 minutes. I
  should see a print statement before these are executed, but I do not.
  Instead it shows up *after* the last 2 lines of code have completed. Is
  there something broken about this?

 My guess is that the output is getting buffered and the buffer doesn't
 get flushed until sometime after the function executes.

 --
 Stand Fast,
 tjg. [Timothy Grant]

Are you calling this function from inside, say, doctests-watched
comments.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Print statement isn't showing up?

2008-08-05 Thread Timothy Grant
On Tue, Aug 5, 2008 at 9:09 AM, Robert Dailey [EMAIL PROTECTED] wrote:
 Hi,

 I have the following code:


 def ReplaceExternalWithCopy( localDir, remoteDir ):
 print Removing external local directory:, localDir
 rmdirs( localDir )
 vfxrepo.copy( remoteDir, localDir )

 I noticed that the print statement above does not show up before
 vfxrepo.copy() is called. the copy() function (as well as the rmdirs()
 function) are very long file-system calls that take up to 5 minutes. I
 should see a print statement before these are executed, but I do not.
 Instead it shows up *after* the last 2 lines of code have completed. Is
 there something broken about this?

My guess is that the output is getting buffered and the buffer doesn't
get flushed until sometime after the function executes.

-- 
Stand Fast,
tjg. [Timothy Grant]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Print statement isn't showing up?

2008-08-05 Thread Robert Dailey
On Tue, Aug 5, 2008 at 2:28 PM, Timothy Grant [EMAIL PROTECTED]wrote:

 On Tue, Aug 5, 2008 at 9:09 AM, Robert Dailey [EMAIL PROTECTED] wrote:
  Hi,
 
  I have the following code:
 
 
  def ReplaceExternalWithCopy( localDir, remoteDir ):
  print Removing external local directory:, localDir
  rmdirs( localDir )
  vfxrepo.copy( remoteDir, localDir )
 
  I noticed that the print statement above does not show up before
  vfxrepo.copy() is called. the copy() function (as well as the rmdirs()
  function) are very long file-system calls that take up to 5 minutes. I
  should see a print statement before these are executed, but I do not.
  Instead it shows up *after* the last 2 lines of code have completed. Is
  there something broken about this?

 My guess is that the output is getting buffered and the buffer doesn't
 get flushed until sometime after the function executes.


That was indeed the case. I'm using Notepad++ to execute my python scripts,
and they have their own little console window. Executing the script directly
in a CMD console works fine.
--
http://mail.python.org/mailman/listinfo/python-list

Re: Print statement isn't showing up?

2008-08-05 Thread Terry Reedy



Robert Dailey wrote:

I have the following code:


Python version?  Plafform?


def ReplaceExternalWithCopy( localDir, remoteDir ):
print Removing external local directory:, localDir
rmdirs( localDir )
vfxrepo.copy( remoteDir, localDir )

I noticed that the print statement above does not show up before 
vfxrepo.copy() is called. the copy() function (as well as the rmdirs() 
function) are very long file-system calls that take up to 5 minutes. I 
should see a print statement before these are executed, but I do not. 
Instead it shows up *after* the last 2 lines of code have completed. Is 
there something broken about this?


There may be a buffering issue.  After the print, try
import sys
sys.stdout.flush()

--
http://mail.python.org/mailman/listinfo/python-list