2021年4月7日星期三

Bracket assignment in Python

I would like to create a class that is able to do the following

class Test:      # code here    test = Test()  test["test"] = 1  test.test  # returns 1  

Is this possible in Python using magic methods (e.g. not inheriting from dict)? Related question here

https://stackoverflow.com/questions/66997054/bracket-assignment-in-python April 08, 2021 at 11:45AM

没有评论:

发表评论