473,666 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is time.time() < time.time() always true?

So, I was blazin' some mad chronix, as they say, and got on to thinking
about Python.

The question was, is the statement:

time.time() < time.time()

always true? Seems it should be false, since the statement itself
occurs at one time instant.. but of course we know that python doesn't
execute code that way.. So my question is, why doesn't Python work this
way?
(PS, I wasn't smoking anything, its a figure of speech :) )

Nov 21 '06 #1
8 1461
On 21 Nov 2006 15:10:25 -0800, flamesrock <fl********@gma il.comwrote:
So, I was blazin' some mad chronix, as they say, and got on to thinking
about Python.

The question was, is the statement:

time.time() < time.time()

always true? Seems it should be false, since the statement itself
occurs at one time instant.. but of course we know that python doesn't
execute code that way.. So my question is, why doesn't Python work this
way?
This would only be false if the time between the 2 calls was less than
the precision of the OS call that time.time uses.
Nov 21 '06 #2
flamesrock wrote:
always true? Seems it should be false, since the statement itself
occurs at one time instant.. but of course we know that python
doesn't execute code that way..
C++ also wouldn't. How could multiple object instantiations be
atomic?

Regards,
Björn

--
BOFH excuse #42:

spaghetti cable cause packet failure

Nov 21 '06 #3
At Tuesday 21/11/2006 20:10, flamesrock wrote:
>The question was, is the statement:

time.time() < time.time()

always true? Seems it should be false, since the statement itself
occurs at one time instant.. but of course we know that python doesn't
execute code that way.. So my question is, why doesn't Python work this
way?
The only thing Python can guarantee, is that the left expression is
evaluated before the right one (5.13 Evaluation order, Language Reference).

Then, whether the first call yields a result always less (or equal)
to the second, is out of Python scope (and control).
(They might be equal if both calls get the same quantum of time; they
might be reversed if some other process sets the time in the past).
--
Gabriel Genellina
Softlab SRL

_______________ _______________ _______________ _____
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
Nov 22 '06 #4
Gabriel Genellina <ga******@yahoo .com.arwrites:
The only thing Python can guarantee, is that the left expression is
evaluated before the right one (5.13 Evaluation order, Language
Reference).
Thanks, that answers my question asked elsewhere.

--
\ "One thing vampire children have to be taught early on is, |
`\ don't run with a wooden stake." -- Jack Handey |
_o__) |
Ben Finney

Nov 22 '06 #5
Hi all:

From my experience with os's.
Time is updated at intervals- they may be as low as 1mS See . So for that
millisecond multiple readings of the time will always return the same
result. Therefore time.time() < time.time() will be false for most readings.

However the result could be true if you catch the exact time when the os
updates its clock. It will only be True for a single execution of the line
and you will have to be lucky to catch it at just the right time.

Of course if you hard loop over the interval its possible to see the
transition.

for x in xrange (10000):
t = time.time()
if t < time.time:
print "transition at ", t

Enjoy.
Andy

"Ben Finney" <bi************ ****@benfinney. id.auwrote in message
news:ma******** *************** *************** @python.org...
Gabriel Genellina <ga******@yahoo .com.arwrites:
>The only thing Python can guarantee, is that the left expression is
evaluated before the right one (5.13 Evaluation order, Language
Reference).

Thanks, that answers my question asked elsewhere.

--
\ "One thing vampire children have to be taught early on is, |
`\ don't run with a wooden stake." -- Jack Handey |
_o__) |
Ben Finney

Nov 22 '06 #6
"flamesrock " <fl********@gma il.comwrote:

8<----------------------------------
.... since the statement itself
occurs at one time instant..
nothing, but nothing, can occur at one time instant....

- Hendrik

Nov 22 '06 #7
"Hendrik van Rooyen" <ma**@microcorp .co.zawrote:
>"flamesrock " <fl********@gma il.comwrote:

8<----------------------------------
>.... since the statement itself
occurs at one time instant..

nothing, but nothing, can occur at one time instant....
Well, as long as we're being pedantic, surely that should read "only one
thing can occur at any time instant..."
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Nov 23 '06 #8
"Tim Roberts" <ti**@probo.com wrote:

"Hendrik van Rooyen" <ma**@microcorp .co.zawrote:
"flamesrock " <fl********@gma il.comwrote:

8<----------------------------------
.... since the statement itself
occurs at one time instant..
nothing, but nothing, can occur at one time instant....

Well, as long as we're being pedantic, surely that should read "only one
thing can occur at any time instant..."
No its worse than that - what I mean is that everything takes finite time...

:-) Hendrik
Nov 24 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
3393
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to <foo/>) From XHTML specification:
13
2492
by: dpj5754 | last post by:
Is there a simple and determinist way to make the difference between the 2 sequences: <XX></XX> and <XX/> The EndElement callback does not provide this information.
2
9158
by: Kevin Lyons | last post by:
Hello, Can anyone assist me with what I am trying to do with the following code (six different scenarios to try to make the functionality work correctly)? I want to always (and ONLY) display in the status bar 'Symantec Corporation' whenever anyone mouses over (onMouseOver) my image or link OR when one clicks while holding the left mouse down (onClick) on the same image or link. Upon releasing the mouse (onMouseOut), the
72
4190
by: Paminu | last post by:
In math this expression: (a < b) && (b < c) would be described as: a < b < c But why is it that in C these two expressions evaluate to something different for the same values of a, b and c?
16
1434
by: kerberoz | last post by:
which is faster? If strMessage <> String.Empty Then End If or If Not strMessage Is Nothing Then
11
2439
by: jesdynf | last post by:
I'm having trouble applying a stylesheet to content I'm generating after the fact. Here's the sample code: <html> <head> <title>CSS/DOM Problem Example</title> <style type="text/css"> ..historylinks {
8
1654
by: pbd22 | last post by:
hi. i have spent the past week (i am afraid) trying to get the below script for uploading files via a hidden iframe to work. i have narrowed down my problem to the possibility that IE doesnt like the fact that the script is instantiating the object type so many times (of course, tell me if i am wrong).
10
5005
by: arnuld | last post by:
It is quite an ugly hack but it is all I am able to come up with for now :-( and it does the requires work. I want to improve the program, I know you people have much better ideas ;-) /* C++ Primer - 4/e * * exercise 9.20 * STATEMENT: * Write a program to to compare whether a vector<intcontains the
2
1694
by: Envergure | last post by:
Is there a way to get the clock time besides clock()? Here's my specific problem: I wrote a little "free camera" application in C++, using OpenGL and SDL. Its camera was controlled with keyboard & mouse, like in a first-person shooter. To see where I was going I had it draw a 50x50x50 cube of octahedra: int i, j, k, l = 500, m = 80; // l is the radius, m is the side length of the volume glBegin (GL_QUADS);
0
8445
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8640
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.