MCPcopy Index your code
hub / github.com/RustPython/RustPython / __repr__

Method __repr__

Lib/tkinter/__init__.py:260–296  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

258 """
259
260 def __repr__(self):
261 attrs = {k: v for k, v in self.__dict__.items() if v != '??'}
262 if not self.char:
263 del attrs['char']
264 elif self.char != '??':
265 attrs['char'] = repr(self.char)
266 if not getattr(self, 'send_event', True):
267 del attrs['send_event']
268 if self.state == 0:
269 del attrs['state']
270 elif isinstance(self.state, int):
271 state = self.state
272 mods = ('Shift', 'Lock', 'Control',
273 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5',
274 'Button1', 'Button2', 'Button3', 'Button4', 'Button5')
275 s = []
276 for i, n in enumerate(mods):
277 if state & (1 << i):
278 s.append(n)
279 state = state & ~((1<< len(mods)) - 1)
280 if state or not s:
281 s.append(hex(state))
282 attrs['state'] = '|'.join(s)
283 if self.delta == 0:
284 del attrs['delta']
285 # widget usually is known
286 # serial and time are not very interesting
287 # keysym_num duplicates keysym
288 # x_root and y_root mostly duplicate x and y
289 keys = ('send_event',
290 'state', 'keysym', 'keycode', 'char',
291 'num', 'delta', 'focus',
292 'x', 'y', 'width', 'height')
293 return '<%s event%s>' % (
294 getattr(self.type, 'name', self.type),
295 ''.join(' %s=%s' % (k, attrs[k]) for k in keys if k in attrs)
296 )
297
298
299_support_default_root = True

Callers

nothing calls this directly

Calls 9

reprFunction · 0.85
getattrFunction · 0.85
isinstanceFunction · 0.85
enumerateFunction · 0.85
lenFunction · 0.85
hexFunction · 0.85
itemsMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected