I didn't understand how to use ** \ _ \ _dict \ _ \ _ in Python. ** ** I saw a good example Shown.
At the following site Using ** \ _ \ _ dict \ _ \ _ **, List of objects that can take the len function as an argument How to find out was shown.
https://python.ms/len/#_1-len-の考え方
>>> builtin_sized_types = []
>>>
>>>
>>> for val in __builtins__.__dict__.values():
... if isinstance(val, type):
... if hasattr(val, '__len__'):
... builtin_sized_types.append(val)
...
>>> print(*builtin_sized_types, sep='\n')
Execution result
<class 'memoryview'>
<class 'bytearray'>
<class 'bytes'>
<class 'dict'>
<class 'frozenset'>
<class 'list'>
<class 'range'>
<class 'set'>
<class 'str'>
<class 'tuple'>
>>>
If you don't get used to it, you can't use it like this. .. .. I feel like I've learned. Please give me any advice.
Recommended Posts