473,748 Members | 7,377 Online
Bytes | Software Development & Data Engineering Community
+ 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,f ilobj,matrix='p am250',begin=0, end='none'):
self.fil = filobj
self.begin = begin
self.end = end
if matrix in MatrixInfo.avai lable_matrices:
######self.matr ix =MatrixInfo.mat rix
self.matrix= MatrixInfo.pam2 50
else print "matrix don't exist %s" %matrix
self.seqnr=0
self.basenr=0
self.dict = {}

Thanks Lars
Jul 18 '05 #1
1 1386
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,f ilobj,matrix='p am250',begin=0, end='none'):
self.fil = filobj
self.begin = begin
self.end = end if matrix in MatrixInfo.avai lable_matrices:
######self.matr ix =MatrixInfo.mat rix
self.matrix= MatrixInfo.pam2 50
else print "matrix don't exist %s" %matrix
Assuming available_matri ces_dict is a dictionary with the matrices' name as
keys:

if matrix in MatrixInfo.avai lable_matrices_ dict:
self.matrix = MatrixInfo.avai lable_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.avai lable_matrices_ dict[matrix]
self.seqnr=0
self.basenr=0
self.dict = {}


Now how will the available_matri ces_dict dictionary come to be?

At the end of MatrixInfo do

available_matri ces_dict = dict([(name, globals()[name]) for name in
available_matri ces])

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

available_matri ces_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
7787
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 any errors or warnings, but in my displayed report, the textobject in question is not being changed. Code: crReport1 Rpt = new crReport1 (); TextObject to = (TextObject) Rpt.ReportDefinition.
0
1531
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 any errors or warnings, but in my displayed report, the textobject in question is not being changed. Code: crReport1 Rpt = new crReport1 (); TextObject to = (TextObject) Rpt.ReportDefinition.
1
2869
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 appreciate to Thanks for your help.
4
3194
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 get public members but not protected, private, static members"
9
2578
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) example: In Project RoObjDefs: RoPerson.cls file: Public Property Get FirstName() as String Public Property Get LastName() as String <end of file RoPerson.cls> RoPersons.cls file Public Function Count() as Integer
1
1951
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
5867
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 ...... Deadlocked Statement: Type : Dynamic Operation: Execute
2
7122
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, Wilfried http://www.mestdagh.biz
1
4742
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, every subreport on separate section and every subreport represents one of simple reports. How can I get access to TextObject which resides in, say, Section1 of the first Subreport? Or can I get access to any Section of Subreport? Smth like:...
0
8989
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9537
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8241
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6073
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3309
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 we have to send another system
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.