About 73,400 results
Open links in new tab
  1. python - How can I add new keys to a dictionary? - Stack Overflow

    You can use the dictionary constructor and implicit expansion to reconstruct a dictionary. Moreover, interestingly, this method can be used to control the positional order during …

  2. dictionary - A Python class that acts like dict - Stack Overflow

    Oct 25, 2010 · A python class that acts like dict What's wrong with this? Can anyone point out why most of the inheritance snippets look like the one below? class CustomDictOne(dict): def …

  3. python - What are dictionary view objects? - Stack Overflow

    In python 2.7, we got the dictionary view methods available. Now, I know the pro and cons of the following: dict.items() (and values, keys): returns a list, so you can actually store the result, and

  4. Python "extend" for a dictionary - Stack Overflow

    Python "extend" for a dictionary Asked 16 years, 8 months ago Modified 2 years, 10 months ago Viewed 552k times

  5. python - How to "perfectly" override a dict? - Stack Overflow

    The MutableMapping implements some things in Python that dict implements in C - so I would expect a dict subclass to be more performant in some cases. We get a free __eq__ in both …

  6. Time complexity of accessing a Python dict - Stack Overflow

    Dec 26, 2009 · The python dict is a hashmap, its worst case is therefore O (n) if the hash function is bad and results in a lot of collisions. However that is a very rare case where every item …

  7. python - Accessing dict keys like an attribute? - Stack Overflow

    Mar 1, 2017 · To access the dict items (and other dict methods) in the usual manner do f()['key'] and we can conveniently update the dict by calling f with keyword arguments and/or a dictionary

  8. How do I merge two dictionaries in a single expression in Python?

    How can I merge two Python dictionaries in a single expression? For dictionaries x and y, their shallowly-merged dictionary z takes values from y, replacing those from x. In Python 3.9.0 or …

  9. Can I add custom methods/attributes to built-in Python types?

    Because, when you define class having 'list' as class name, you will no longer be able to access the 'in-built list' class methods as 'list' is treated as a user-defined class rather than a inbuilt …

  10. python - How to test if a dictionary contains a specific key? - Stack ...

    Feb 5, 2017 · How to test if a dictionary contains a specific key? [duplicate] Asked 14 years, 8 months ago Modified 5 years, 9 months ago Viewed 552k times