Hello...hopeful ly my last question :-)
I ave a dictionary, where each value is a class instance. I access it
using:
for k, v in self.panels.pan el_list.items() :
print "Number:\t",v.n umber
print "Level:\t",v.le vel
print "Location:\t",v .location
print "MOPS:\t",v.mop s
print "List length:\t",len( v.mops)
print "Matrix:\t",v.m atrix,"\n\n"
The output from this would be (for a given key value):
Number: 181
Level: ovride+supvis
Location: mons=4 v8.0 3rd floor
MOPS: ['287', '288', '289', '290']
List Length: 28
Matrix: kng
This is really odd...my len(v.mops) ought to return 4 (4 elements in
the list). In fact it returns 28. looking at outputs from lots of
records, it seems that the length is almost always 7 time too great
(28/7=4)....but not always. This is really confusing...can anyon
suggest what is going on?
I've been trying to output the list elements as a string with equally
limmited success, but the thing seems so simple I can't see where the
prblem might lie....
Cheers,
Ben 16 1133
Ben wrote:
The output from this would be (for a given key value):
Number: 181
Level: ovride+supvis
Location: mons=4 v8.0 3rd floor
MOPS: ['287', '288', '289', '290']
List Length: 28
Matrix: kng
This is really odd...my len(v.mops) ought to return 4 (4 elements in
the list).
adding a
print type(v.mops), repr(v.mops)
debug statement might provide you with the clues you need.
In fact it returns 28. looking at outputs from lots of
records, it seems that the length is almost always 7 time too great
(28/7=4)....but not always.
>>len("['287',")
7
>>len(" '288',")
7
>>len(" '289',")
7
>>len(" '290']")
7
</F>
Ah... my list is a string. That explains the len() results, but not why
it is a string in the dirst place.
I have a dictionary containing a number of instances of the following
class as values:
class panel:
mops =[]
def __init__(self,n umber,level,loc ation,mops,matr ix):
self.number=num ber
self.level=leve l
self.location=l ocation
self.mops=mops
self.matrix=mat rix
abve mops is a list, yet when I access it it is a string...
Fredrik Lundh wrote:
Ben wrote:
The output from this would be (for a given key value):
Number: 181
Level: ovride+supvis
Location: mons=4 v8.0 3rd floor
MOPS: ['287', '288', '289', '290']
List Length: 28
Matrix: kng
This is really odd...my len(v.mops) ought to return 4 (4 elements in
the list).
adding a
print type(v.mops), repr(v.mops)
debug statement might provide you with the clues you need.
In fact it returns 28. looking at outputs from lots of
records, it seems that the length is almost always 7 time too great
(28/7=4)....but not always.
>>len("['287',")
7
>>len(" '288',")
7
>>len(" '289',")
7
>>len(" '290']")
7
</F>
....and when I print out the string, it is still formatted as one would
expect a list to be:
<type 'str'"['01', '02', '03', '04']"
Ben wrote:
Ah... my list is a string. That explains the len() results, but not why
it is a string in the dirst place.
I have a dictionary containing a number of instances of the following
class as values:
class panel:
mops =[]
def __init__(self,n umber,level,loc ation,mops,matr ix):
self.number=num ber
self.level=leve l
self.location=l ocation
self.mops=mops
self.matrix=mat rix
abve mops is a list, yet when I access it it is a string...
Fredrik Lundh wrote:
Ben wrote:
The output from this would be (for a given key value):
Number: 181
Level: ovride+supvis
Location: mons=4 v8.0 3rd floor
MOPS: ['287', '288', '289', '290']
List Length: 28
Matrix: kng
>
This is really odd...my len(v.mops) ought to return 4 (4 elements in
the list).
adding a
print type(v.mops), repr(v.mops)
debug statement might provide you with the clues you need.
In fact it returns 28. looking at outputs from lots of
records, it seems that the length is almost always 7 time too great
(28/7=4)....but not always.
>>len("['287',")
7
>>len(" '288',")
7
>>len(" '289',")
7
>>len(" '290']")
7
</F>
Ben wrote:
Ah... my list is a string. That explains the len() results, but not why
it is a string in the dirst place.
I have a dictionary containing a number of instances of the following
class as values:
class panel:
mops =[]
def __init__(self,n umber,level,loc ation,mops,matr ix):
self.number=num ber
self.level=leve l
self.location=l ocation
self.mops=mops
self.matrix=mat rix
abve mops is a list, yet when I access it it is a string...
Well, if you are going to spare us from reading all of your code,
you'll have to debug it yourself. The clue that Fredrik gave you is
*not* of the use-once-and-discard variety -- when you are having
problems with the pixies changing your lists into strings, you need to
sprinkle prints of type(pixie_prey ) and repr(pixie_prey ) at salient
points in your code; as first statement in that __init__ method would
be a good start.
Ben wrote:
Ah... my list is a string. That explains the len() results, but not why
it is a string in the dirst place.
I have a dictionary containing a number of instances of the following
class as values:
class panel:
mops =[]
def __init__(self,n umber,level,loc ation,mops,matr ix):
self.number=num ber
self.level=leve l
self.location=l ocation
self.mops=mops
self.matrix=mat rix
abve mops is a list, yet when I access it it is a string...
Well, if you are going to spare us from reading all of your code,
you'll have to debug it yourself. The clue that Fredrik gave you is
*not* of the use-once-and-discard variety -- when you are having
problems with the pixies changing your lists into strings, you need to
sprinkle prints of type(pixie_prey ) and repr(pixie_prey ) at salient
points in your code; as first statement in that __init__ method would
be a good start.
Thanks for the advice - I'm already doing just that, so hopefully will
soon be sorted :-p
John Machin wrote:
Ben wrote:
Ah... my list is a string. That explains the len() results, but not why
it is a string in the dirst place.
I have a dictionary containing a number of instances of the following
class as values:
class panel:
mops =[]
def __init__(self,n umber,level,loc ation,mops,matr ix):
self.number=num ber
self.level=leve l
self.location=l ocation
self.mops=mops
self.matrix=mat rix
abve mops is a list, yet when I access it it is a string...
Well, if you are going to spare us from reading all of your code,
you'll have to debug it yourself. The clue that Fredrik gave you is
*not* of the use-once-and-discard variety -- when you are having
problems with the pixies changing your lists into strings, you need to
sprinkle prints of type(pixie_prey ) and repr(pixie_prey ) at salient
points in your code; as first statement in that __init__ method would
be a good start.
Ben wrote:
...and when I print out the string, it is still formatted as one would
expect a list to be:
<type 'str'"['01', '02', '03', '04']"
We know that. Fredrik deduced it and told you well over an hour ago.
Show us the code that is creating instances of the panel class ...
panel1 =
panel(number=?, level=?,locatio n=?,mops=?????? ??????????,matr ix=?)
What are you passing as the 4th positional arg
^^^^^^^^^^^^^^^ ^^^^^^^^ ???
On 8 Oct 2006 06:12:48 -0700, John Machin <sj******@lexic on.netwrote:
>
Show us the code that is creating instances of the panel class ...
panel1 =
panel(number=?, level=?,locatio n=?,mops=?????? ??????????,matr ix=?)
What are you passing as the 4th positional arg
^^^^^^^^^^^^^^^ ^^^^^^^^ ???
This is wholly unnecessary.
-- Theerasak
Theerasak Photha wrote:
On 8 Oct 2006 06:12:48 -0700, John Machin <sj******@lexic on.netwrote:
Show us the code that is creating instances of the panel class ...
panel1 =
panel(number=?, level=?,locatio n=?,mops=?????? ??????????,matr ix=?)
What are you passing as the 4th positional arg
^^^^^^^^^^^^^^^ ^^^^^^^^ ???
This is wholly unnecessary.
-- Theerasak
What is wholly unnecessary? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: nick |
last post by:
In the web site http://greywolfdesign.com , there is a pop-up menu (when
mouse over 'Portfolio' menu item), it always works well when using IE (6).
However, when using Mozilla 1.6, the popup works well for all the pages
except the 4 pages which can be opened by click the menu link in the
popup. In these four pages, the popup will always be shown at the
leftmost of its parent div (flow) instead of under the 'Portfolio' menu
item.
When...
|
by: Richard Gutery |
last post by:
I have an ASP page that I need to have a Message Box on. When I try to run
the page, I get the following message :
Exception Not Handled. Permission Denied.
To trouble shoot, I gave everyone FC on the Page. Same error.
I've never seen or heard of this before. Any Ideas out there?
Richard
|
by: BCC |
last post by:
I am getting a non-reproduceable release mode only error, that is
proving to be really a pain. I can in some cases narrow it down by
try/catch blocks but even that behavior is totally f*ed up.
For example, I have this gem:
try {
int x = Foo();
}
catch (...) {
int x = Foo();
|
by: Zri Man |
last post by:
I have come across a bizzare behaviour with DB2/UDB 8.2 on SuSE Linux
2.41
When I have a MQT Refresh going on (complete refresh) it appears to
lock the underlying base tables used to build the MQT.
When I attempt to SELECT these tables in other sessions, it simply
refuses to yield and are waiting for the MQT to finish.
Any clues ? Is this the intended behaviour?
|
by: Josef.Szeliga |
last post by:
I have a most unusual problem that i cannot work out.
I have a pie chart on my report which when you click on one of the
pieces calls itself and drills down into the data.
This method works like a dream. However, my users run their reports
from a .net application which uses a javascript command
windows.open(url) where the url holds the url of the server, report and
any parameters.
| |
by: Martin Pritchard |
last post by:
Hi,
Sorry for my ignorance, but I'm a bit new to C++.
I've been handed over a C++ app written in VS2002 which I have to convert to
VS2005. Apparently it's been written in a C style, but cannot comment
myself!
Following the conversion I have numerous errors, which following some
digging around turns out to be because _export is obsolete, and
|
by: the.duckman |
last post by:
G'Day,
I have a simple peice of code behaving in a rather eratic manner.
outputStreams = new MemoryStream();
//.... some code to add values to the stream ...
bool ready = false;
//.... some code...
ready = (outputStreams.Length > 0);
|
by: PT |
last post by:
Hi,
I've a simple XML tree that is essentially.
<?xml version="1.0"?>
<Project>
<Version Version="1.001" />
<Platform Name="Platform1"/>
<Platform Name="Platform2" />
</Project>
|
by: Okonita |
last post by:
Hello Gurus,
At about 11:00 am this morning, tried to connect to an instance of DB2 UDB v8.
2 fixpak 14 on a Red Hat Linux environment. The message returned say DB2
alias not found. Alarmed, we researched extensively and found that all data
and files in the /sqllib is gone...vamosed!!
Called system folks for help and we are still trying to recover as I write.
Question: (1) Anyone faced this kind of situation before and how did they...
|
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...
|
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...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |