Is there an equivalent of __DATE__ and __TIME__ in Python?
+2
A:
If you're talking about the C macros, no. This is unsurprising, as Python doesn't have either macros or a real compilation step (it can generate pyc and pyo files, but that's not the same as compiling to native code). If you need something like this (to tell you when it was built), you will have to define "built" and implement it yourself.
Matthew Flaschen
2010-07-19 12:45:27
sounds like a job for your respective version control system
THC4k
2010-07-19 12:54:13
+2
A:
Python doesn't have the same compilation process as C so there aren't macros to use, but if you wanted something quick and dirty the __file__
global variable stores the name of the current Python file so you could check when this file was modified to give you something a bit like a build date:
import os, time
print time.ctime(os.path.getmtime(__file__))
Dave Webb
2010-07-19 13:06:17