[Tutor] lockfiles and timestamps and nested if's!
Lance E Sloan
lsloan@umich.edu
Thu, 17 May 2001 19:07:16 -0400
kromag@nsacom.net wrote:
> lockfile=open('\tmp\'+mybox, 'r')
> timestamp=lockfile.readline()
> print timestamp
> lockfile.close()
> if timestamp > time.time()-10:
This is probably not the cause of your problem, and it may not be a
problem at all. It might just be me being a Python newbie.
Anyway, in the second line that I quoted above, wouldn't timestamp be a
string? If so, what will happen when the string is compared with a
number on the fifth line?
I suspect that the condition will always fail or always pass because
timestamp is a string (probably with a trailing CR and/or LF) and is
very different from the float returned by time.time(). Whether it will
be pass or fail, I don't know. I'm not sure how Python would compare
those two datatypes.
--
Lance E Sloan
Web Services, Univ. of Michigan: Full-service Web and database design,
development, and hosting. Specializing in Perl & Python CGIs.
http://websvcs.itd.umich.edu/ - "Putting U on the Web"