Converting String to Class

Matt Gerrans matt.gerrans at
Wed Dec 1 21:15:49 CET 2004

You didn't specify exactly how the string is parsed, so this is a guess:

class Thingy(object):
   def __init__(self,rawinfo):
      self.StructId, vq,self.ProcessName = rawinfo.split()
      self.Version,self.QName = vq.split('.')
   def __str__(self):
      return '<Thingy: StructId: %s, Version: %s, QName: %s, ProcessName: %s 
 >' % (self.StructId, self.Version, self.QName, self.ProcessName)

t = Thingy( "TMC    2TEST.QUEUE     LV1871.MQPROCESS" )
str(t) -> '<Thingy: StructId: TMC, Version: 2TEST, QName: QUEUE, 
ProcessName: LV1871.MQPROCESS >'

- mfg 

More information about the Python-list mailing list