MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / sort_attributes

Function sort_attributes

tools/python-3.11.9-amd64/Lib/pydoc.py:326–336  ·  view source on GitHub ↗

Sort the attrs list in-place by _fields and then alphabetically by name

(attrs, object)

Source from the content-addressed store, hash-verified

324 return results
325
326def sort_attributes(attrs, object):
327 'Sort the attrs list in-place by _fields and then alphabetically by name'
328 # This allows data descriptors to be ordered according
329 # to a _fields attribute if present.
330 fields = getattr(object, '_fields', [])
331 try:
332 field_order = {name : i-len(fields) for (i, name) in enumerate(fields)}
333 except TypeError:
334 field_order = {}
335 keyfunc = lambda attr: (field_order.get(attr[0], 0), attr[0])
336 attrs.sort(key=keyfunc)
337
338# ----------------------------------------------------- module manipulation
339

Callers 2

docclassMethod · 0.85
docclassMethod · 0.85

Calls 3

enumerateFunction · 0.85
getMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected