I am trying to run a script from http://aug.ment.org/dvd/makespumux.py used to convert subtitles to graphics.
The file I am reading looks like:
Code: Select all
1
00:00:20,000 --> 00:00:24,400
Altocumulus clouds occur between six thousand
2
00:00:24,600 --> 00:00:27,800
and twenty thousand feet above ground level.
snip
Code: Select all
def IsInt( str ):
""" Is the given string an integer? """
ok = 1
try:
num = int(str)
except ValueError:
ok = 0
return ok
***It does not catch the first "1" in the file!!!
From the Python manual:
int([x[, base]])¶
Convert a string or number to a plain integer. If the argument is a string, it must contain a possibly signed decimal number representable as a Python integer, possibly embedded in whitespace. The base parameter gives the base for the conversion (which is 10 by default) and may be any integer in the range [2, 36], or zero. If base is zero, the proper radix is determined based on the contents of string; the interpretation is the same as for integer literals. (See Numeric literals.) If base is specified and x is not a string, TypeError is raised. Otherwise, the argument may be a plain or long integer or a floating point number. Conversion of floating point numbers to integers truncates (towards zero). If the argument is outside the integer range a long object will be returned instead. If no arguments are given, returns 0.
Sooo... My question is: How can you check to see if the character "1" is an int or not if the command only accepts "the range [2, 36], or zero"
If I put a blank line at the beginning of the file, it works. (?)
Is there a reason "1" is different, and is there a trick to testing it?
Thanks
Lyle
(I hate registering for a bunch of sites, so since everyone here is so helpfull I thought I would ask here first)