Consider this data class derived from the pydantic
package:
from typing import List
from pydantic import BaseModel
class Bucket(BaseModel):
setting: List[str]
fight_1: List[int]
cause_1: List[str]
let my_bucket
be an instance of Bucket
:
my_bucket = Bucket(setting=['some_value'], fight_1=[0], cause_1=['other_value'])
basically I would like to be able to do
my_bucket['setting']
and get back ['some_value']
, but instead I get:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-18-cacbdc1698e9> in <module>
----> 1 my_bucket['setting']
TypeError: 'Bucket' object is not subscriptable