newbie question - python blocking on int()?

Bjorn Pettersen BPettersen at NAREX.com
Mon Jun 10 23:48:03 EDT 2002


> From: Michael Davis [mailto:michael at damaru.com] 
> 
> Chris Liechti wrote:
> 
> > Michael Davis <michael at damaru.com> wrote in
> > news:4LaN8.2488$Vr2.586019 at news20.bellglobal.com:
> >> I'm writing a specialized ftp client. I'm parsing the 
> output of ftp.dir,
> >> which gives me a string like this (call it str):
> >> 
> >> -rw-r--r--   1 fred       527 Jun  4 22:58 report.php
> >> 
> >> and I'm getting the various parts like this:
> >> 
> >> details = string.split( str )
> >> permissions = details[0]
> >> size = details[3]
> >> name = details[7]
> >> debug( "added remote file size %5d: %s" % (int(size), name) )
> >> 
> >> This works. But when I replace the 3rd line with this:
> >> 
> >> size = int( details[3] )
> >> 
> >> python hangs on that line. Why?
> > 
> > not when i try it... what do you mean by "hangs" does it 
> takes forever or
> > do you see an error message? if its the later, then you might have
> > assigned something to "int" somewhere else, hiding the 
> builtin function.
> 
> Thanks for replying. Actually, it's the former - when I say 
> 'hangs', I mean 
> that the program appears to stop running at that point. If I write:
> print "one"
> size = int( details[3] )
> print "two"
> 
> it prints "one" but not "two".

Try inserting

  print '[%s]' % details[3]

before you convert to an int (that will at least let you know for sure
what int is trying to conver...)

hth,
-- bjorn





More information about the Python-list mailing list