Pythonでは、次のようなことができます。
d = dict()
i = int()
f = float()
l = list()
しかし、文字列のコンストラクタはありません
>>> s = string()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'string' is not defined
何故ですか?または、文字列型のコンストラクターはありますか?
また、上記の定義に従って、
d['a'] = 1
動作しますが
>>> l[0] = 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: list assignment index out of range
ではない。
誰かが私にこれを説明できますか?