Joe McDonnell has posted comments on this change. ( http://gerrit.cloudera.org:8080/18125 )
Change subject: IMPALA-11070: Create TestSection class. ...................................................................... Patch Set 4: > I still think a custom class is actually cleaner overall, but I'm > going to look into a different solution. Hold off on further > comment, since I may end up abandoning this review. One short path to implementing the dictionary interface is to subclass UserDict: from UserDict import UserDict class joetest(UserDict): def __init__(self, test_key, test_value): UserDict.__init__(self) # self.data is the underlying dictionary. Putting things in there makes them available. self.data[test_key] = test_value self.data["EXAMPLE_{0}".format(test_key)] = test_value j = joetest("foo", "bar") print(j["foo"]) print(j.keys()) print("EXAMPLE_foo" in j) print("not_exist" in j) The actual interface functions are the container interfaces: https://docs.python.org/3/reference/datamodel.html?emulating-container-types#emulating-container-types There are a variety of ways of doing these things. You can also subclass dict and there are a bunch of different container classes. My main thought is that it is hard to judge these things in abstract. If there is some detail you want to provide about the use case you have in mind, then I may end up agreeing that a class is the way to do things. -- To view, visit http://gerrit.cloudera.org:8080/18125 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I3fed7ef64ac263b49b5b6e4a237a296092e4dcb8 Gerrit-Change-Number: 18125 Gerrit-PatchSet: 4 Gerrit-Owner: Steve Carlin <scar...@cloudera.com> Gerrit-Reviewer: Impala Public Jenkins <impala-public-jenk...@cloudera.com> Gerrit-Reviewer: Joe McDonnell <joemcdonn...@cloudera.com> Gerrit-Reviewer: Steve Carlin <scar...@cloudera.com> Gerrit-Comment-Date: Thu, 13 Jan 2022 03:39:44 +0000 Gerrit-HasComments: No