473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Converting String to Class

Hello,

I have a script that is called by the shell this way :

mqtrigger.py "TMC 2TEST.QUEUE LV1871.MQPROCESS"

So argv[1] is the string "TMC 2TEST.QUEUE LV1871.MQPROCESS"

I would like to construct a class with that string that contains the
attributes

-StrucId
-VersionId
-QName
-ProcessName

I am thinking about using the following info

opts = [['StrucId', CMQC.MQTMC_STRUC_ID, '4s'],
['Version', CMQC.MQTMC_VERSION_2, '4s'],
['QName', '', '48s'], ## or less :-)
['ProcessName', '', '48s']] ## or less :-)

1. is the attributename
2. is the default
3. is the format in the string

So the string could be parsed with the opts Info and the attributes
could be inserted into the class. I dont even have a starting point
how to do that. Could somebody point my into the right direction

Regards

Michael
Jul 18 '05 #1
1 1532
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
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Asbjørn Ulsberg | last post by:
Hi. I'm trying to convert Brady Hegberg's great RTF2HTML VB 6.0 module to C#. I've managed to convert the VB code to VB.NET, which gave me the following code: Option Strict On Option...
9
by: Edward Diener | last post by:
I received no answers about this the first time I posted, so I will try again. My inability to decipher an MSDN topic may find others who have the same inability and someone who can decipher and...
2
by: Asbjørn Ulsberg | last post by:
Hi. I'm trying to convert Brady Hegberg's great RTF2HTML VB 6.0 module to C#. I've managed to convert the VB code to VB.NET, which gave me the following code: Option Strict On Option...
9
by: Terry | last post by:
I am converting (attempting) some vb6 code that makes vast use of interfaces. One of the major uses is to be able to split out Read-only access to an obect. Let me give you a simple (contrived)...
25
by: Blasting Cap | last post by:
I keep getting errors that pop up when I am trying to convert an application from dotnet framework 1.1 to framework 2.0. The old project was saved in sourcesafe from Visual Studio 2003, and I have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.