Skip to content
Advertisement

Tag: generator

Remove duplicate JSON objects from list in python

I have a list of dict where a particular value is repeated multiple times, and I would like to remove the duplicate values. My list: function to remove duplicate values: When I call this function I get generator object. When I try to iterate over the generator I get TypeError: unhashable type: ‘dict’ Is there a way to remove the

Is enumerate in python lazy?

I’d like to know what happens when I pass the result of a generator function to python’s enumerate(). Example: Is the enumeration iterated lazily, or does it slurp everything into the <enumerate object> first? I’m 99.999% sure it’s lazy, so can I treat it exactly the same as the generator function, or do I need to watch out for anything?

Understanding generators in Python

I am reading the Python cookbook at the moment and am currently looking at generators. I’m finding it hard to get my head round. As I come from a Java background, is there a Java equivalent? The book …

Advertisement