By default, many web3.eth properties and methods return an AttributeDict. This object behaves like a standard Python dict but allows you to access keys as attributes. Note that AttributeDict objects are immutable; attempting to modify a field will raise a TypeError.
Warning on Type Hinting: Accessing properties via attribute (e.g., block.number) will break type hinting. If your application requires strict typing, access values using standard dictionary key syntax (e.g., block['number']) or remove the AttributeDictMiddleware.
>>> block = web3.eth.get_block('latest')
AttributeDict({
'hash': '0xe8ad537a261e6fff80d551d8d087ee0f2202da9b09b64d172a5f45e818eb472a',
'number': 4022281,
})
>>> block['number']
4022281
>>> block.number
4022281
>>> block.number = 4022282
Traceback ...
TypeError: This data is immutable -- create a copy instead of modifying