Ticket #44574

generate_packets.py: phase out use of __dict__ in formatting

Open Date: 2022-05-13 05:19 Last Update: 2022-05-16 21:14

Reporter:
Owner:
Type:
Status:
Closed
Component:
MileStone:
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
Fixed
File:
1

Details

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
  • Resolution Update from None to Accepted
Comment

Depends on #44563 and #44576

2022-05-16 21:14 Updated by: alienvalkyrie
  • Resolution Update from Accepted to Fixed
2022-05-16 21:14 Updated by: alienvalkyrie
  • Status Update from Open to Closed

Edit

Please login to add comment to this ticket » Login