Python中的"Allocable Resource"和"Container"有什么区别?

What is the difference between "Allocable Resource" and "Container" in Python?

我正在学习数据结构。 我已经知道 Python 个容器是:List、Tuple、Set 和 Dictionary。

在一个 Python 测验问题中,有一个问题必须确定以下 class 中哪些是重载给定方法列表的方法。

但是我不明白Python中Allocable resource的概念。指的是栈、队列、二叉树吗?

所以,我使用 dir() 来深入每个 class 并找出它们是否具有问题中指示的方法。

    """A classs overloads the following methods. Which of the following best describes objects
of this class?

__len__
__contains__
__getitem__
__setitem__

A) Generator
B) Iterator
C) Numeric
D) Allocable resource
E) Container
"""
# A) Generator
"""Is not a class"""
# B) Iterator
"""
dir(iter) = 
['__call__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', 
'__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__',
 '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', 
 '__reduce_ex__', '__repr__', '__self__', '__setattr__', 
'__sizeof__', '__str__', '__subclasshook__', '__text_signature__']"""
# C) Numeric
"""dir(25) = 
['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', 
'__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', 
'__format__', '__ge__', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__index__',
 '__init__', '__init_subclass__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__',
  '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__',
   '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', 
   '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', 
   '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__',
    '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 
    'conjugate', 'denominator', 'from_bytes', 'imag', 'numerator', 'real', 'to_bytes']"""
# D) Allocable resource
"""???"""
# E) Container
"""Python's general purpose built-in containers, dict , list , set , and tuple """
"""dir(list) = 
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dir__',
 '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', 
 '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__init_subclass__', 
 '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', 
 '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__'
 , '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'clear', 
 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']"""

正确答案是 Allocable 资源在 Python 中是一个含糊不清的术语,Python 容器是对问题中描述的方法可用的容器。