Dictionaries are Causing Issues
See original GitHub issueLet’s say this is the input.
d = {
'name': 'name',
'image': 'img.img',
'short': 'something short',
'tags': ['science', 'entertainment'],
'videos': [{'name': 'Intro',
'url': 'https://player.vimeo.com/video/414517859'},
{'name': 'Code', 'url': 'https://player.vimeo.com/video/414517885'},
{'name': 'Plotting', 'url': 'https://player.vimeo.com/video/414517957'},
{'name': 'How it Works 1',
'url': 'https://player.vimeo.com/video/414518015'},
{'name': 'How it Works 2',
'url': 'https://player.vimeo.com/video/414518059'},
{'name': 'Accuracy', 'url': 'https://player.vimeo.com/video/414518106'},
{'name': 'Benchmark', 'url': 'https://player.vimeo.com/video/414518141'},
{'name': 'Final Features',
'url': 'https://player.vimeo.com/video/414518199'}]
}
Then what should come out of this?
Clumper(d).map(lambda d: [d]).collect()
Not this;
[['name'], ['image'], ['short'], ['tags'], ['videos']]
Yet that is exactly what is happening! The root cause for this is that we currently allow dictionaries to be read in via all of our read_
functions. The issue lies in the map
method. It assumes a list of dictionaries. We should consider a decorator that can detect this but maybe we should also be more strict when we create a clumper object.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
The problem with dictionaries | | The Guardian
In reality it is not surprising because even one of the large single volume dictionaries contains only about 170,000 words and phrases. This ......
Read more >dictionary - Features and problems | Britannica
In the temporal categories, labels such as obsolete, obsolescent, archaic, and old-fashioned are dangerous because some speakers have long memories and might ...
Read more >Boolean as key in dictionary is causing weird problems?
I am new to Python and I am currently learning about dictionaries. I was putting random values and types in a dictionary.
Read more >DICTIONARY DEFINITIONS: PROBLEMS AND SOLUTIONS*
The aim of the present article is threefold: to examine certain problems inherent in dictionary defining; to discuss the most important changes that...
Read more >Cause a problem definition and meaning - Collins Dictionary
A problem is a situation that is unsatisfactory and causes difficulties for people. [...] See full entry. Collins COBUILD Advanced Learner's Dictionary.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For the calmcode.io project I want to be able to read in many yaml files. Something like;
The annoying thing is that here (version 0.2.6) the same problem occurs. The read functions currently do not return a list of dictionaries. I think it can be fine to also allow dictionaries because that makes the library more flexible (there’s a lot of nasty data out there) but I’m thinking about adding a flag to the
read_
methods that turn a dictionary into a list containing the single dictionary.Should be fixed now by https://github.com/koaning/clumper/pull/60