PDA

View Full Version : a piss poor script, really...


inkedmn
08-02-2002, 05:51 AM
whipped this up for cheekyzombie a minute ago, thought it was kinda cool

converts seconds UTC to a readable date format:

import time, sys

def convertTime(x): return time.ctime(x)
if len(sys.argv) != 2:
print "Usage: " + sys.argv[0] + " <current time in seconds>"
sys.exit()
else:
try:
x = float(sys.argv[1])
print convertTime(x)
except Exception, e:
print e
sys.exit()

it's fun, whatever... :)

inkedmn
08-02-2002, 06:31 AM
oh, and windows users, i just compiled this little prog into a .exe using py2exe (never used it before, pretty easy)

anyhow, works the same way (pass the seconds as an arg)

http://www.inkedmn.net/code/convtime.zip

Benny
08-02-2002, 11:50 AM
nice....

Hmm think I might add to this thread - this utterly useless script:


#!/usr/bin/env python

char = "!"
int = 75

spacer = int/2

range = []

while int > 0:
range.append(int)
int = int-2

range.reverse()

for x in range:
print " "*spacer+char*x
spacer=spacer-1


Will print a triangle made up of char and the size of int.

hehe very very useless, but I was bored at work and started converting bits of pracs I had to do for uni into python code (as opposed to C ), hence triangle.py.

Enjoy.

*EDIT* - Why do the code tags put a newline between every line?

GnuVince
08-02-2002, 01:34 PM
Benny: the problem happens only with non-IE web browsers. We once asked for a fix, but it never happened.

Strike
08-02-2002, 01:38 PM
inkdemn: you could use import to rename a module that you import:


from time import ctime as convertTime


would have worked instead of defining the function as a wrapper. :)

jemfinch
08-03-2002, 12:54 AM
Hey, Benny, long time no see! You're Ben Briggs, right?

Anyway, if you are, have you seen my bot? Check it out -- http://www.sf.net/projects/supybot/ -- you'll enjoy coding on it, I'm sure.

inkedmn: Check out time.strftime for a way to format your time/dates even cooler :)

Jeremy

Benny
08-03-2002, 04:53 AM
Originally posted by jemfinch
Hey, Benny, long time no see! You're Ben Briggs, right?

Anyway, if you are, have you seen my bot? Check it out -- http://www.sf.net/projects/supybot/ -- you'll enjoy coding on it, I'm sure.


Nup, not Ben Briggs (remember him from LNO though), sorry to disappoint.

:goofy: - oooh new smilies.