About 48,100 results
Open links in new tab
  1. python - Create a dictionary with comprehension - Stack Overflow

    Python supports dict comprehensions, which allow you to express the creation of dictionaries at runtime using a similarly concise syntax. A dictionary comprehension takes the form {key: …

  2. Python Dictionary Comprehension - Stack Overflow

    711 There are dictionary comprehensions in Python 2.7+, but they don't work quite the way you're trying. Like a list comprehension, they create a new dictionary; you can't use them to add keys …

  3. Dictionary Comprehension in Python 3 - Stack Overflow

    I found the following stack overflow post about dict comprehensions in Python2.7 and Python 3+: Create a dictionary with list comprehension in Python stating that I can apply dictionary …

  4. python - How can I use if/else in a dictionary comprehension?

    Feb 25, 2012 · Another example in using if/else in dictionary comprehension I am working on data-entry desktop application for my own office work, and it is common for such data-entry …

  5. Nested dictionary comprehension python - Stack Overflow

    Jul 29, 2013 · I haven't found an example of a nested dictionary comprehension like this; Googling "nested dictionary comprehension python" shows legacy examples, non-nested …

  6. Python Dictionary comprehension for a list of dictionaries

    Jan 25, 2017 · I am puzzled too. I think it is safe to assume that when the question asks about dictionary comprehensions that we are talking about a Python version that supports dictionary …

  7. python - Make a dictionary (dict) from separate lists of keys and ...

    To make a dictionary from separate lists of keys and values, based on a subset of the keys/values, use dictionary comprehension. To subset by the value, use zip.

  8. python - Why is this loop faster than a dictionary comprehension …

    Oct 16, 2018 · The list comprehension speed advantage comes from this difference; see Python list comprehension expensive What a dict comprehension does add, is that the target …

  9. Conditional expressions in Python Dictionary comprehensions

    Aug 15, 2013 · Conditional expressions in Python Dictionary comprehensions Asked 12 years, 4 months ago Modified 7 years, 3 months ago Viewed 51k times

  10. dictionary - Using List Comprehension with Dictionaries in Python ...

    May 4, 2015 · Using List Comprehension with Dictionaries in Python Asked 10 years, 7 months ago Modified 10 years, 7 months ago Viewed 20k times