All pastes #838394 Raw Edit

getPacificTime.py

public text v1 · immutable
#838394 ·published 2007-12-30 09:44 UTC
rendered paste body
#!/usr/bin/env python
#coding=utf-8
#getPacificTime.py (From Python tutorial, section 10.7)
import urllib2
print
print
def gpt():
    for line in urllib2.urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl'):
        if 'PST' in line or 'PDT' in line:
             print line[13:]

while True:
    gpt()
    again = raw_input('Again? Enter nothing (for "yes") or n (for "no"): ')
    if again == 'n':
        print "Bye."
        break