newbie question - python blocking on int()?

Michael Davis michael at
Mon Jun 10 23:16:36 EDT 2002

Chris Liechti wrote:

> Michael Davis <michael at> wrote in
> news:4LaN8.2488$Vr2.586019 at
>> 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".

As far as the other points go, luckily I'm in control of all the file names, 
and I can ensure that none has spaces. Spaces in filenames were always a 
terrible idea, I think. And I didn't call the string 'str', I called it 
'line', which I don't think is a reserved word or function name.


> note that you should not use "str" as a name as that is a builtin
> object/function that can be very handy. e.g. in python 2.2+ you could have
> written "details = str.split(line)"
> (or even "details = line.split()" which i prefer)
> also note that split() might not be safe for every case. e.g when the user
> name contains a space (if possible) and surely when the filename has a
> space in it.
> chris

Michael Davis
Custom Programming - Web Development - Database Design

More information about the Python-list mailing list