473,320 Members | 2,164 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,320 software developers and data experts.

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.regionlist.append(list(self.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.comwrote:
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.regionlist), 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 955

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

Similar topics

73
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...
6
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...
1
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...
11
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...
2
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...
6
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);...
5
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...
1
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...
13
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.