Data dodania Pytanie
2017-08-05 16:08 Why python dict.keys() order will change every time when the key is class object? »
The output of keys() order will change each time when key is class object. class test: def __init__(self, path): self.path = path de...
(1) odpowiedzi
2017-08-04 14:08 cpython 3.6 dict order in dict comprehension »
Since in CPython 3.6 dicts are ordered (I know it's not guaranteed - yet awesome to use), so I expected the following dict comprehension to preserve t...
(1) odpowiedzi
2017-08-03 12:08 How to convert returned array to dictionary with Swift 3 »
I'm using FB API to get the list of user's page likes. But i'm stuck with converting array (the array is the return data from FB API) to dictionary. ...
(1) odpowiedzi
2017-08-02 20:08 Sort dictionary into list »
There are already a lot of questions about sorting dictionaries but I can't find the right answer to my question. I have the dictionary v: v = {3:4...
(7) odpowiedzi
2017-08-02 13:08 Should I use put() or putIfAbsent() after using getOrDefault()? »
Java8 introduced those nice methods getOrDefault() and putIfAbsent(), allowing to write code like: Map<Foo, List<Bar>> itemsByFoo = ... L...
(2) odpowiedzi
2017-08-02 01:08 is there a way to add in more dict after inside an append? django »
Apologize if the title is a bit hard to understand. Not too sure how to explain it within a line. What I want to do is... actually I have this code ...
(2) odpowiedzi
2017-08-01 17:08 create a dictionary with incrementing values »
I have a list and I want to generate a dictionary d taking out duplicates and excluding a single item, such that the first key has value 0, the second...
(5) odpowiedzi
2017-07-27 11:07 How can OrderedDict know about the element order of an already instantiated dict? »
I was playing around with the OrderedDict type in Python 3.6 and was surprised by its behaviour. When I create a simple dict like this in IPython: d ...
(3) odpowiedzi
2017-07-21 10:07 Convert dict of nested lists to list of tuples »
I have dict of nested lists: d = {'a': [[('a1', 1, 1), ('a2', 1, 2)]], 'b': [[('b1', 2, 1), ('b2', 2, 2)]]} print (d) {'b': [[('b1', 2, 1), ('b2', 2,...
(2) odpowiedzi
2017-07-20 16:07 Does std::map assign its comparator? »
Is std::map copy assignment (in style map1 = map2;) required to copy comparator of map2 to map1? I have tested that actual implementations do that. ...
(2) odpowiedzi
2017-07-20 00:07 Python Dict() maintaining entered ordered »
It was my understanding that a dictionary's order was guaranteed but not predictable. That is, it will always be in the same order but that order is n...
(0) odpowiedzi
2017-07-18 14:07 Fill std::map with std::generate_n »
I'd like to fill a std::map using std::generate_n but can't get it to work. What I tried is something along these lines: unsigned number_of_pairs{5};...
(2) odpowiedzi
2017-07-15 15:07 Use of a swift dictionary returns all its values? »
I have the swift dictionary myD, that has enums of type myEnum as keys, and () functions as values. When I try the function of one of the keys, all fu...
(1) odpowiedzi
2017-07-10 19:07 how to rescursively deep merge an array of objects »
I want to merge two arrays of objects. Those objects have the same structure, but one of them is missing the hide property. I want to copy the value o...
(2) odpowiedzi
2017-07-10 17:07 pprint sorting dicts but not sets? »
I know that dicts and sets aren't ordered, so equal sets or dicts may print differently (all tests with Python 3.6.1): >>> for obj in {0, 8}...
(1) odpowiedzi
2017-07-09 13:07 python - Executing transform function on parameter dict when creating new transformdict »
I've read about this cool new dictionary type, the transformdict I want to use it in my project, by initializing a new transform dict with regular di...
(3) odpowiedzi
2017-07-05 10:07 Search dictionary values and return List of keys meeting conditions »
I've got a problem searching a Dictionary looking like this. Dictionary<string, string[]> dic = new Dictionary<string, string[]>(){ ...
(2) odpowiedzi
2017-07-05 09:07 Generator expressions Python »
I have a list of dictionaries like the following: lst = [{'a': 5}, {'b': 6}, {'c': 7}, {'d': 8}] I wrote a generator expression like: next((itm fo...
(5) odpowiedzi
2017-07-03 05:07 Generic parameter 'Element' could not be inferred when adding to Array »
I have a dictionary of arrays: var myDict : [String:[SomeObj]] = [:] To populate it, I try to add a value to the array at the correct index. If the...
(2) odpowiedzi
2017-06-23 22:06 Creating a dictionary for each word in a file and counting the frequency of words that follow it »
I am trying to solve a difficult problem and am getting lost. Here's what I'm supposed to do: INPUT: file OUTPUT: dictionary Return a dictionary wh...
(5) odpowiedzi
2017-06-22 20:06 How can I take two tuples to produce a dictionary? »
My first thought is to write an interator, or maybe do some list comprehension. But, like every 5-10 line method I write in python, someone can usual...
(2) odpowiedzi
2017-06-22 19:06 Does declaring variables in a function called from __init__ still use a key-sharing dictionary? »
I've tried to always declare class attributes inside the __init__ for clarity and organizational reasons. Recently, I've learned that strictly followi...
(2) odpowiedzi
2017-06-18 05:06 How to extend Scala Maps: implementing get and iterator »
I'm making a custom SparseMatrix in Scala as an exercise. I want to do this by extending the immutable map. The functionality should be something like...
(0) odpowiedzi
2017-06-16 20:06 Can I change the way keys are compared in a Python dict? I want to use the operator 'is' instead of == »
Let's say I have two objects of a same class: objA and objB. Their relationship is the following: (objA == objB) #true (objA is objB) #false ...
(2) odpowiedzi
2017-06-16 16:06 Dictionary initializer has different behavior and raises run-time exception when used in combination of array initializer »
I have the following C# code which initializes a new dictionary with int keys and List<string> values: var dictionary = new Dictionary<i...
(2) odpowiedzi
2017-06-16 02:06 What is the most pythonic way to re-order a class objects' attributes? »
I'm in the process of creating a set of Python 2.7/3+ tools to programmatically modify the contents of XML files my team uses constantly. So far, I'm ...
(2) odpowiedzi
2017-06-15 13:06 Understanding the max function operation on Python dictionary »
I am trying to understand the operation on max function on Python dictionary. Following is the code I am using: tall_buildings = { "Empire State...
(3) odpowiedzi
2017-06-14 08:06 How to make a dictionary of dictionaries with multiple lists »
There is one index list which will be the key of the parent dictionary: index = [1,2,3] and then multiple lists of which will be the child dicts: ...
(7) odpowiedzi
2017-06-13 22:06 When does __eq__ gets called using hash()? »
As mentioned here, Below code, class Person(object): def __init__(self, name, ssn, address): self.name = name self.ssn = ssn ...
(2) odpowiedzi
2017-06-13 12:06 Add Dictionaries Keys Values to Array [JavaScript] »
Here is a sample of my data structure in JavaScript: var list = [{"username":"admin1"}, {"username":"admin2"}, {"username":"admin3"}, {"username":"a...
(2) odpowiedzi
2017-06-07 20:06 A dictionary with a unique possible value for each key? »
I need to create a map from twitter status IDs to their author ID. Obviously, each status has exactly one author. I expected Python collections to ha...
(0) odpowiedzi
2017-06-07 05:06 In c# , how to iterate IEnumerable in multithreading environment »
I am in this situation that there is a large dictionary that is randomly updated by one thread at a fairly high frequency, and there is another thread...
(3) odpowiedzi
2017-06-01 10:06 How can I filter a dictionary with arbitrary length tuples as keys efficiently? »
TL;DR What is the most efficient way to implement a filter function for a dictionary with keys of variable dimensions? The filter should take a tuple...
(4) odpowiedzi
2017-05-31 13:05 Convert type X to Y in Map<K, Map<V, X>> using Java Stream API »
I want to convert inner map from map of maps. Old map: Map<String, Map<LocalDate, Integer>> Integer means seconds New map: Map<String...
(9) odpowiedzi
2017-05-30 22:05 Searching for dictionary keys contained in a string array »
I have a List of strings where each item is a free text describing a skill, so looks kinda like this: List<string> list = new List<string&gt...
(4) odpowiedzi