待辦事項 #44574

generate_packets.py: phase out use of __dict__ in formatting

啟用日期: 2022-05-13 05:19 最後更新: 2022-05-16 21:14

回報者:
負責人:
類型:
狀態:
關閉
元件:
里程碑:
優先權:
5 - 中
嚴重程度:
5 - 中
處理結果:
修正
檔案:
1

細節

Part of #43927. Accessing instance variables for string interpolation via an object's __dict__ makes it impossible to use properties (or any other descriptors), and makes it less clear that an instance variable is being used (e.g. searching for ".name" would not find these uses).

While f-strings (the preferred formatting solution) are only available from Python 3.6 onward, str.format() supports member access; e.g. "%(foo)s, %(bar)s" % self.__dict__ can be written as "{self.foo}, {self.bar}".format(self = self).

Ticket History (3/5 Histories)

2022-05-13 05:19 Updated by: alienvalkyrie
  • New Ticket "generate_packets.py: phase out use of __dict__ in formatting" created
2022-05-13 05:42 Updated by: alienvalkyrie
  • 處理結果 Update from to Accepted
評語

Depends on #44563 and #44576

2022-05-16 21:14 Updated by: alienvalkyrie
  • 處理結果 Update from Accepted to 修正
2022-05-16 21:14 Updated by: alienvalkyrie
  • 狀態 Update from 開啟 to 關閉

編輯

Please login to add comment to this ticket » 登入