473,788 Members | 2,892 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dictionary containing a list

Ben
Hello...

I have set up a dictionary into whose values I am putting a list. I
loop around and around filling my list each time with new values, then
dumping this list into the dictionary. Or so I thought...

It would appear that what I am dumping into the dictionary value is
only a pointer to the original list, so after all my iterations all I
have is a dictionary whose every value is equal to that of the list the
final time I looped around :-(

Is there a way to acheive what I was attempting ? I have done something
almost identical with classes in a list before, and in that case a new
instance was created for each list entry...
I hope this makes some sense, and doesn't seem to head bangingly
simple...
Cheers,

Ben

Oct 6 '06
10 2341
"Fredrik Lundh" <fr*****@python ware.comwrote:

Steve Holden wrote:
One of the fascinating things about c.l.py is that sometimes a questin
will be posted that makes almost no sense to me, and somebody else will
casually read the OP's mind, home in on the issue and provide a useful
and relevant answer.

if the assertions made by some about the documentation's unsuit-
ability for some are in fact true, that's probably some kind of
natural selection in action.

</F>
LOL - Whining about documentation is what programmers do - its driven by the
"fact" that the docs and the implementation are "never" in sync, except on
something that is either trivial, or as old as the hills...

And it does not matter if the software is free and open source, or bought at
great expense - there are always these differences - sometimes niggly, and often
major - it sometimes looks as if the docs were a statement of intent, with the
implementation taking a left turn at the first crossroads.

- Hendrik
- Hendrik

Oct 9 '06 #11

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

Similar topics

90
10824
by: Christoph Zwerschke | last post by:
Ok, the answer is easy: For historical reasons - built-in sets exist only since Python 2.4. Anyway, I was thinking about whether it would be possible and desirable to change the old behavior in future Python versions and let dict.keys() and dict.values() both return sets instead of lists. If d is a dict, code like: for x in d.keys():
4
2045
by: Alexandre Brisebois (www.pointnetsolutions.com) | last post by:
Hi, I am currently building a lexical analysis component to pull keywords out of content, I currently have a functional first build, but I am having problems ince I am easily loading over 300 000 strings in memory, when I am doing the actual analysis I can reach upto 400 mb of ram usage.
4
2244
by: Nico Grubert | last post by:
Hi there, I am looking for a way to sort a list containing dictionaries. This is my example list: I want to sort the list by dictionary's key 'from_datetime' so the sorted list should be:
14
3474
by: vatamane | last post by:
This has been bothering me for a while. Just want to find out if it just me or perhaps others have thought of this too: Why shouldn't the keyset of a dictionary be represented as a set instead of a list? I know that sets were introduced a lot later and lists/dictionaries were used instead but I think "the only correct way" now is for the dictionary keys and values to be sets. Presently {1:0,2:0,3:0}.keys() will produce but it could also...
11
14471
by: John Henry | last post by:
Hi list, I am sure there are many ways of doing comparision but I like to see what you would do if you have 2 dictionary sets (containing lots of data - like 20000 keys and each key contains a dozen or so of records) and you want to build a list of differences about these two sets. I like to end up with 3 lists: what's in A and not in B, what's in B and not in A, and of course, what's in both A and B.
7
1181
by: Ben | last post by:
Hello... I have a dictionary, where each value is a seperate instance of the same class: self.mop_list=record(self.mops) In my case I know that record_number takes the values 0,3,and 7 thanks to a loop, giving me three instances of the record class instantiaterd with some data I've pased in.
6
1708
by: asincero | last post by:
Which is better: using an if/else construct to simulate a C switch or use a dictionary? Example: def foo(): if c == 1: doCase1() elif c == 2: doCase2() elif c == 3: doCase3()
5
1984
by: robinsiebler | last post by:
I have a data structure that looks like this: # dates = {'2007': {'25': {'06/23/07': {'aerosmith': , # 'Metallica': }, # 'last_song': }}} I have a section where I try to loop through a set of dates and print out all of the songs for a given artist: if type == 'artist':
2
5897
by: Assimalyst | last post by:
Hi I have a Dictionary<string, List<string>>, which i have successfully filled. My problem is I need to create a filter expression using all possible permutations of its contents. i.e. the dictionary essentially creates the following array: Key Value
0
9656
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
10175
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 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...
0
9969
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
8993
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
7518
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
5399
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
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
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
2894
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.