473,491 Members | 2,552 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

converting textobject to name of other object.

I'm trying to use the matrix variable to collect a matrix in the file
MatrixInfo which contains a lot of different matrices. Yhe commented line is
the problem.
HOW ???????

import re
import MatrixInfo

class Diff:
def __init__(self,filobj,matrix='pam250',begin=0,end=' none'):
self.fil = filobj
self.begin = begin
self.end = end
if matrix in MatrixInfo.available_matrices:
######self.matrix =MatrixInfo.matrix
self.matrix= MatrixInfo.pam250
else print "matrix don't exist %s" %matrix
self.seqnr=0
self.basenr=0
self.dict = {}

Thanks Lars
Jul 18 '05 #1
1 1372
Lars Tengnagel wrote:
I'm trying to use the matrix variable to collect a matrix in the file
MatrixInfo which contains a lot of different matrices. Yhe commented line
is the problem.
HOW ???????
import re
import MatrixInfo

class Diff:
def __init__(self,filobj,matrix='pam250',begin=0,end=' none'):
self.fil = filobj
self.begin = begin
self.end = end if matrix in MatrixInfo.available_matrices:
######self.matrix =MatrixInfo.matrix
self.matrix= MatrixInfo.pam250
else print "matrix don't exist %s" %matrix
Assuming available_matrices_dict is a dictionary with the matrices' name as
keys:

if matrix in MatrixInfo.available_matrices_dict:
self.matrix = MatrixInfo.available_matrices_dict[matrix]
else:
print "matrix don't exist %s" %matrix

or a bit more pythonic, since a Diff instance with an unknown matrix
probably doesn't make much sense:

# you have to handle the exception outside of
# Diff.__init__()
self.matrix = MatrixInfo.available_matrices_dict[matrix]
self.seqnr=0
self.basenr=0
self.dict = {}


Now how will the available_matrices_dict dictionary come to be?

At the end of MatrixInfo do

available_matrices_dict = dict([(name, globals()[name]) for name in
available_matrices])

Or you drop the available_matrices list (I suppose) altogether and use a
dict literal instead

available_matrices_dict = {"pam250": pam250, ...}

Peter

Jul 18 '05 #2

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

Similar topics

0
7741
by: Matt Theule | last post by:
Visual Studio 2002, Crystal Reports.NET I am unable to set the text of a text object in a crystal reports report. I have found lots of examples for doing this, and what I have does not throw...
0
1522
by: Matt Theule | last post by:
Visual Studio 2002, Crystal Reports.NET I am unable to set the text of a text object in a crystal reports report. I have found lots of examples for doing this, and what I have does not throw...
1
2849
by: Eric | last post by:
Hi, Can somebody tell me a way to change the value of a textobject in a report at runtime. By the way if anyone know a way to know how many page my report are going to had in code it will be...
4
3170
by: gg9h0st | last post by:
i'm a newbie studying php. i was into array part on tutorial and it says i'll get an array having keys that from member variable's name by converting an object to array. i guessed "i can...
9
2534
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)...
1
1937
by: Josep Blanch | last post by:
Hi, I'm making a report with Crystal Reports and I use a TextObjet witch I assign a string, but I need to show the text in multiline. How I could do it? Thanks!
2
5847
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 .........
2
7105
by: Wilfried Mestdagh | last post by:
Hi, I'm trying to find my way in my first crystalreport. To make a summary I need of course put text and results on it. There is a TextObject, but how do I reach it from code ? -- rgds,...
1
4725
by: MizukaEno | last post by:
Hello, experts. I'm using C# to create WinForms application with Crystal Reports as a reporting tool. I have three very simple table-like reports and I have one report with three subreports,...
0
7115
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
7154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7190
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...
0
7360
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.