[Tutor] Popen? or something else
zmerch at 30below.com
Wed Dec 22 19:25:05 CET 2004
Rumor has it that Ertl, John may have mentioned these words:
>I hate to ask this but I have just installed 2.4 and I need to get some info
>from a subprocess (I think that is correct term).
>At the Linux command line if I input dtg I get back a string representing a
>date time group. How do I do this in Python? I would think Popen but I
>just don't see it.
It could, but there's also a better (IMHO), 'pythonic' way, something like
today = time.strftime('%Y%m%d%H',time.localtime(time.time()))
If you wanted to use popen, it would look rather like this:
dtg_s = os.popen("/path/to/dtg").readlines()
But this may use more system resources (spawning child shells & whatnot)
than doing everything internally with the time module in Python.
Roger "Merch" Merchberger
Roger "Merch" Merchberger | A new truth in advertising slogan
SysAdmin, Iceberg Computers | for MicroSoft: "We're not the oxy...
zmerch at 30below.com | ...in oxymoron!"
More information about the Tutor