dictionary Questions

4

Solved

I'm new to Python and I was reading about Dictionaries. And from my previous experience with languages like Javascript, they seemed like objects to me. Dictionaries can store lists and share many s...
Allanallana asked 8/1, 2014 at 5:11

2

Solved

How do I express the type of a Dict which has two keys that take two different types of values? For example: a = {'1': [], '2': {}) The following is just to give you an idea of what I am looking...
Barrio asked 2/1, 2018 at 1:5

6

I am looking at using the ES6 Map object to do my hashing for me, instead of creating a custom hashing function. However, it seems to me that it doesn't have much support for immutability, which is...
Rip asked 15/12, 2018 at 20:6

5

Solved

I've been looking for a way to store and retrieve values on more than the single key that C#'s generic Dictionary class provides. Searching around the web (and on SO itself) has shown me a couple ...
Prynne asked 10/8, 2012 at 20:44

26

Given: [ {"name": "Tom", "age": 10}, {"name": "Mark", "age": 5}, {"name": "Pam", "age": 7} ] How do I s...
Dow asked 28/12, 2011 at 8:25

9

Solved

I am trying to build a heap with a custom sort predicate. Since the values going into it are of "user-defined" type, I cannot modify their built-in comparison predicate. Is there a way to...
Lester asked 16/1, 2012 at 4:16

46

Solved

If I have an object implementing the Map interface in Java and I wish to iterate over every pair contained within it, what is the most efficient way of going through the map? Will the ordering of ...
Pesek asked 5/9, 2008 at 21:12

20

Solved

How do I delete an item from a dictionary in Python? Without modifying the original dictionary, how do I obtain another dict with the item removed? See also How can I remove a key from a Python di...
Ovoid asked 30/4, 2011 at 21:20

10

Solved

IntelliJ spellchecker comes with only English and Arabic bundled (strange, I think it is made in east Europe, they didn't even bundle their language?). My customer is German so all my code is mixed...
Zarathustra asked 22/12, 2009 at 23:58

10

Solved

If I have a list of dictionaries, say: [{'id': 1, 'name': 'paul'}, {'id': 2, 'name': 'john'}] and I would like to remove the dictionary with id of 2 (or name 'john'), what is the most efficient...
Reba asked 5/8, 2009 at 20:41

4

Solved

This is more of a general, best-practices question. I've been playing around here and there with JavaScript Maps and have been trying to find more info on whether or not it's considered an anti-pa...
Victorie asked 4/12, 2018 at 4:35

4

Solved

I come from a python world where only hashable objects may be used as keys to a dictionary. Is there a similar restriction in C#? Can you use custom types as dictionary keys?
Sinew asked 6/9, 2013 at 8:19

14

Solved

A frozen set is a frozenset. A frozen list could be a tuple. What would a frozen dict be? An immutable, hashable dict. I guess it could be something like collections.namedtuple, but that is m...
Fahlband asked 24/4, 2010 at 7:19

11

Solved

I want to write a custom class that behaves like dict - so, I am inheriting from dict. My question, though, is: Do I need to create a private dict member in my __init__() method?. I don't see the ...
Wellfounded asked 25/10, 2010 at 12:42

12

Solved

How do I append one Dictionary to another Dictionary using Swift? I am using the AlamoFire library to send JSON content to a REST server. Dictionary 1 var dict1: [String: AnyObject] = [ kFacebook:...
Osvaldooswal asked 4/11, 2014 at 5:43

7

Solved

I have a list of tuples which I want to convert to a Series. return array2 [(0, 0.07142857142857142), (0, 0.07142857142857142), (1, 0.08333333333333333), (1, 0.3333333333333333), (1, 0.33333...
Alton asked 18/11, 2018 at 17:34

8

Solved

I need to be able to find an item in a list (an item in this case being a dict) based on some value inside that dict. The structure of the list I need to process looks like this: [ { 'title': 's...
Institution asked 16/8, 2011 at 13:53

19

Solved

I have a list of dicts, and I'd like to remove the dicts with identical key and value pairs. For this list: [{'a': 123}, {'b': 123}, {'a': 123}] I'd like to return this: [{'a': 123}, {'b': 123}] ...
Dc asked 24/2, 2012 at 7:46

10

Solved

I am trying to make a Dictionary lookup table in C#. I need to resolve a 3-tuple of values to one string. I tried using arrays as keys, but that did not work, and I don't know what else to do. At t...
Encrust asked 5/6, 2009 at 13:56

4

Solved

I'm trying to understand some code which is using this class below: class Base(object): def __init__(self, **kwargs): self.client = kwargs.get('client') self.request = kwargs.get('request') .....
Ricker asked 6/2, 2020 at 22:33

6

Solved

I have the following dictionary dict1 ={"city":"","name":"yass","region":"","zipcode":"", "phone":"","address":"","tehsil":"", "planet":"mars"} I am trying to create a new dictionary that will ...
Prentice asked 22/5, 2013 at 13:59

6

I have a sqlite database with a table with following columns : id(int) , name(text) , dob(text) I want to insert following dictionary to it : {"id":"100","name":"xyz","dob":"12/12/12"} Dictio...
Abettor asked 6/6, 2012 at 11:14

8

Solved

I am trying to store an Environment Variable that Python can read in as a Dictionary. If this is a bad idea, please let me know your suggestions, I am eager to learn. I'm worried that if I st...
Pyrogen asked 13/9, 2014 at 18:37

7

This piece of code is giving me an error TypeError: unhashable type: dict Can anyone explain to me what the solution is? negids = movie_reviews.fileids('neg') def word_feats(words): return dict([...
Bamford asked 7/11, 2012 at 6:47

21

Solved

I have two dictionaries, and I need to find the difference between the two, which should give me both a key and a value. I have searched and found some addons/packages like datadiff and dictdiff-ma...
Karyn asked 28/9, 2015 at 4:20

© 2022 - 2024 — McMap. All rights reserved.