pydoc > weakref.WeakValueDictionary

📖 Name

weakref.WeakValueDictionary — A mapping class that references values weakly. Entries are discarded when no strong reference to the value exists.

🚀 Quick Reference

Use CaseCommandDescription
Create a weak-value dictionaryWeakValueDictionary()Empty dictionary, or initialize with other mapping/iterable
Get value by keyd[key]Returns the value, raises KeyError if missing
Set valued[key] = valueStores a weak reference to value
Delete entrydel d[key]Removes the key-value pair
Check membershipkey in dReturns True if key exists
Get with defaultd.get(key, default=None)Return value or default if missing
Iterate keysiter(d) or d.keys()Returns an iterator over keys
Iterate valuesd.values()Returns a view of values (weak references may be dead)
Iterate itemsd.items()Returns a view of key-value pairs
Pop itemd.pop(key, *args)Remove and return value; raises KeyError if missing and no default
Pop arbitrary itemd.popitem()Remove and return (key, value) pair; raises KeyError if empty
Set defaultd.setdefault(key, default=None)Return value if key exists, else set and return default
Update from another mappingd.update(other, **kwargs)Merge keys/values from other and keyword arguments
Copyd.copy()Returns a shallow copy (values are still weak references)
Clear all entriesd.clear()Remove all items (inherited from MutableMapping)
Get weak refs to valuesd.valuerefs()Returns a list of weak reference objects to values
Iterate weak refs to valuesd.itervaluerefs()Returns an iterator of weak reference objects

📝 Description

Mapping class that references values weakly. Entries in the dictionary will be discarded when no strong reference to the value exists anymore.

🏗️ Method Resolution Order

⚙️ Methods Defined Here

📦 Data Descriptors Defined Here

📦 Data and Other Attributes Defined Here

🔗 Methods Inherited from collections.abc.MutableMapping

🔗 Methods Inherited from collections.abc.Mapping

🔗 Data and Other Attributes Inherited from collections.abc.Mapping

🔗 Class Methods Inherited from collections.abc.Collection

🔗 Class Methods Inherited from collections.abc.Iterable

weakref.WeakValueDictionary
📖 Name 🚀 Quick Reference 📝 Description 🏗️ Method Resolution Order ⚙️ Methods Defined Here 📦 Data Descriptors Defined Here 📦 Data and Other Attributes Defined Here 🔗 Methods Inherited from collections.abc.MutableMapping 🔗 Methods Inherited from collections.abc.Mapping 🔗 Data and Other Attributes Inherited from collections.abc.Mapping 🔗 Class Methods Inherited from collections.abc.Collection 🔗 Class Methods Inherited from collections.abc.Iterable

Generated by phpman v4.9.27-5-g2cb901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-20 04:13 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^