473,770 Members | 3,912 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: More than one element of list changing when only one should be

I solved this problem. I still don't understand why, but it seems
Python was appending a reference to the first element at the end of
the list, rather than copying the data. I used something like:
"self.regionlis t.append(list(s elf.regionlist[self.hregion])"
and now it works fine, i.e., altering the appended list member doesn't
change the copied one.

-Chuckk
On Sat, Jun 7, 2008 at 5:53 PM, Chuckk Hubbard
<ba************ *@gmail.comwrot e:
Hello.
This program is clunky, I know; I'm not a programmer, but I need to
use this program, so I'm writing it.
The problem:
I have a cursor following the mouse that shows frequency ratios of
potential notes in relation to 1/1 (something like Middle C). At any
time, the user may hit "t" to move 1/1 to wherever the cursor is.
There is also the option to use many regions, so that some of the
notes in the score, in region 0, for instance, can have 1/1 as their
base, and others, in region 1 for instance, could have perhaps 3/2 as
their base.

The program starts out with 2 existing regions, region 0 = 1/1, and
region 1 = 3/2. If the user hits r+NUM, the cursor switches to region
NUM. If NUM is longer than the list of regions (self.regionlis t), a
new region is appended with the same base as the current one, and the
cursor goes to that region.

SO, if you start this program, then:
1) move the cursor around a little;
2) hit 'r' and '1' at the same time - now you are in region 1;
3) hit 'r' and '0', now region 0;
4) hit 'r' and '2', now a new region 2 is created with the same
parameters as region 0, and self.regionlist is appended with the new
info - now you're in region 2;
5) move the mouse until the fraction reads anything other than 1/1;
6) hit 't' to transpose the current region by that fraction;

You can see by the output in the text window that self.regionlist[0]
AND self.regionlist[2] have been updated. Only [2] should have been
changed.

7) hit 'r' and '0', and see that region 0 has now changed its base to
match region 2.

I hope someone is curious enough to get through this and help me. I
tried extracting the function in question into its own mini-file and
the problem didn't happen. I can't think of any reason these lines:

self.regionlist[self.hregion][0] = self.curnum
self.regionlist[self.hregion][1] = self.curden
self.regionlist[self.hregion][3] = self.octave11 = self.yadj

should change self.regionlist[0] AND self.regionlist[2] in the same
call, but they do. Also, if I add more regions in series, they all
update each other.

Thanks for your time.

-Chuckk

--
http://www.badmuthahubbard.com


--
http://www.badmuthahubbard.com
Jun 27 '08 #1
0 977

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

Similar topics

73
8072
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities as a standard portable part of the core language, the LISP package, and the java.lang package, respectively. Both have big integers, although only LISP has rationals as far as I can tell. Because CL supports keyword arguments, it has a wider range...
6
2467
by: Wole Ogunremi | last post by:
I guess this is a well asked question but it is tripping me up! I'm putting a forum together allowing xhtml markup content. I am validating against a schema but getting "Could not find schema information for element <elementName>... I would appreciate if anyone could advice where I am going wrong. TIA Here's my xsd:
1
10154
by: Rod Early | last post by:
I need to know when the select element's dropdown list is opened (as when the user clicks on the arrow or does ALT-downarrow from the keyboard). Similarly, I need to known when the dropdown list closes. The closing of the dropdown list can happen without changing the dropdown, hence the onchange event is not a sure way to determine that the dropdown list closed. Is this possible in Internet Explorer?
11
1772
by: dhplank | last post by:
Hello everyone, I've developed a calendar program in javascript, and up until now I've done most of my testing using Mozilla and Firefox. Everything works fine, but when I try to use Internet Explorer my response time is sometimes 50 times slower than using Mozilla. I know I haven't given you much to go by, but I'm not looking for an answer so much as an approach to debugging the problem. For example, does anyone here know of a good...
2
2270
by: Rob Long | last post by:
Hi I have an HTML select element in my page and it's multiple property is disabled (one item at a time mode) but I still want to transfer all the items in the select to the server when the form is submitted. I'm using javascript to change the multiple property of the select element to true and then I'm looping through each option to change its selected property to true.
6
2791
by: Jakob Bieling | last post by:
Hi, I want to move an element from a std::list to the end of the same list. To get this done, I thought I'd just do something like: std::list <intlst; lst.push_back (0); lst.push_back (1); lst.push_back (2); lst.splice (lst.end (), lst, lst.begin (), ++ lst.begin ());
5
4027
by: mantrid | last post by:
Hello Im trying to find the correct syntax to use to determine whether which form element is visible on changing the value in a dropdown list I need something in the onChange of the dropdown list that will cause the appropriate element on another part of the page to be displayed pseudo code below var mydropdownlist =
1
1183
by: Chuckk Hubbard | last post by:
Hello. This program is clunky, I know; I'm not a programmer, but I need to use this program, so I'm writing it. The problem: I have a cursor following the mouse that shows frequency ratios of potential notes in relation to 1/1 (something like Middle C). At any time, the user may hit "t" to move 1/1 to wherever the cursor is. There is also the option to use many regions, so that some of the notes in the score, in region 0, for instance,...
13
8757
by: andypb123 | last post by:
Hello, The onchange event fires in IE6 in a SELECT element when scrolling through the list with the up and down arrows on the keyboard. In Firefox it only fires after you hit the enter key, which is the behaviour I want make happen in IE. Does anyone know how to accomplish this? Thanks a lot Andy Birchall
0
10237
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...
0
9882
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 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...
0
8905
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...
1
7431
isladogs
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...
0
6690
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();...
0
5326
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...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3987
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
3
2832
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.