guids and super(str)
Clark C. Evans
cce at clarkevans.com
Thu May 1 23:07:05 EDT 2003
Ok. I'm trying to make a GUID object, so that, when I nmake a new
one, it generates the guid for me. Two questions. First, is the
method below an "ok" way to make a guid? And second, why doesn't
this override of str work propertly, ie, I'd like the string value
to be the generated guid...
class Identifier(str):
macaddr = os.popen('/sbin/ifconfig -a | grep ether','r').readline()
macaddr = "".join(macaddr.split()[1].split(":")).upper()
def __init__(self):
val = hex(long(time.time()*1000000))[2:]
val = "%s:%s" % (macaddr,val)
str.__init__(self,val)
x = Identifier()
but x is always blank on Python 2.2.2, even though val isn't.
Thanks!
Clark
More information about the Python-list
mailing list