86,264 questions
5
votes
1
answer
100
views
UserDict.popitem is not LIFO
Consider the following snippet:
from collections import UserDict
class D(dict): ...
d = D(foo="bar", baz=42)
print(d.popitem()) # ('baz', 42)
class UD(UserDict): ...
ud = UD(foo="...
-4
votes
0
answers
35
views
Sorting a flat list to hierarchial nested dict when ONLY when parent is known [duplicate]
This post is followup to Nested dict with parent/child relation,, which was closed due to duplication. However, after 3 days....I will give it a try again.
To problem is following. I am trying to sort ...
Advice
2
votes
5
replies
63
views
Why do I get a TypeError when indexing a dictionary .items() result?
I am working with a dictionary in Python and trying to use the .items() function to get the key-value pairs. I saved the result in a variable l, but when I try to access the first element using l[0], ...
1
vote
1
answer
58
views
How to write a JSON string into an in-memory table in DolphinDB?
I am trying to fetch JSON data from an HTTP API and convert it into an in‑memory table in DolphinDB. The JSON response is an array of objects, and I want to store it as a table where each object ...
Advice
0
votes
4
replies
105
views
Dictionary and list handling
i would like to ask for some kind of projects in python that will help me get better at handling dict and lists i'm still not feeling very comfortable with these. If anybody knows a site for training ...
-1
votes
0
answers
112
views
List inside dictionary repeating the same element indefinitely
Note: Someone in the first iteration of this question said that CheckForMagicPoint() is being called every frame, but it is not, as checkingForMagicPoints is only set to true when someone is using the ...
-7
votes
0
answers
67
views
how to delete key in dictionary in python using for loop without using list? [closed]
dic2={'26MC01':{'Name':'Plato', 'Course':'MCA', 'Current Semester':'2nd', 'Graduation Year':'2027'},
'26MC02':{'Name':'Jupiter', 'Course':'MBA', 'Current Semester':'2nd', 'Graduation Year':'...
1
vote
1
answer
58
views
Split 2-dimensional list into a list of dictionaries with ansible
How do you turn a list of lists (2-dimensional) into a list of dicts in Ansible? I don't see how I can map it.
Take this list:
parent_list:
- - "value1-1"
- "value1-2"
- - &...
2
votes
2
answers
83
views
Using Python to group returned data from multiple table joins in MySQL
My database includes treatments (treatment_id) that are given to patients at different times during the day (due_time). I would like to display this in a GUI where each treatment has its own row and ...
1
vote
3
answers
68
views
Ansible split based on a list of strings and with the input being a list
I'm tying find good a way to split multiple FQDN domain names from a list of domains in ansible. I need to split the domain name and the unqualified name into a dictionary.
input_fqdns:
- 'host1....
-4
votes
1
answer
91
views
To what json object a Java List<String> and Map<String, String> corresponds with Jackson?
To what json object will the following java objects get converted / serialized when using jackson mapper?
List<String> textList = new ArrayList<>;
textList.add("one");
textList....
Best practices
3
votes
10
replies
235
views
How do I create a dictionary of dictionaries in Python?
I have two Python dictionaries, d1 and d2. Let them be:
d1 = {'a': 1, 'b': 2}
d2 = {'a': 3, 'b': 4}
Those dicts would be united as a new one, say new_dict:
new_dict = {1: {'a': 1, 'b': 2}, 2: {'a': 3,...
-3
votes
3
answers
118
views
How to create a member function for map?
I have created a map like this:
map<string, map<string, map<int, vector<int>>>> example;
I can insert a value to this map like this:
example["Stack"]["OverFlow&...
-1
votes
1
answer
81
views
Why does dict.update() overwrite nested dictionaries instead of merging them? [duplicate]
I’m working on merging configuration dictionaries while building a small script. I expected dict.update() to merge nested dictionaries, but it seems to completely overwrite them instead.
base = {
&...
6
votes
2
answers
168
views
What is the difference between 'Map.entry(k, v)' and 'AbstractMap.SimpleImmutableEntry::new'?
What is the difference between Map::entry and AbstractMap.SimpleImmutableEntry::new?
I tried to do research, and I really couldn't find much. It seems like Map::entry is a factory method, while ...