Feature or enhancement
Proposal:
Now python suggest for attribute possible in this way:
obj=exc_value.objtry:
try:
d=dir(obj)
exceptTypeError: # Attributes are unsortable, e.g. int and strd=list(obj.__class__.__dict__.keys()) +list(obj.__dict__.keys())
d=sorted([xforxindifisinstance(x, str)])
hide_underscored= (wrong_name[:1] !='_')
ifhide_underscoredandtbisnotNone:
whiletb.tb_nextisnotNone:
tb=tb.tb_nextframe=tb.tb_frameif'self'inframe.f_localsandframe.f_locals['self'] isobj:
hide_underscored=Falseifhide_underscored:
d= [xforxindifx[:1] !='_']
exceptException:
returnNone
However, the obj may has no attribute "__dict__" if it has the attribute "__slots__". So list(obj.__class__.__dict__.keys()) + list(obj.__dict__.keys()) is not safe. And the class must have the attribute "__name__" that the object of the class cannot get.
In fact, the object.__dir__ is safer, it can exactly find all of the attribute that can be get with object.__getattribute__. So I think that we can change the way by using this way.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
Feature or enhancement
Proposal:
Now python suggest for attribute possible in this way:
However, the obj may has no attribute "__dict__" if it has the attribute "__slots__". So
list(obj.__class__.__dict__.keys()) + list(obj.__dict__.keys())is not safe. And the class must have the attribute "__name__" that the object of the class cannot get.In fact, the
object.__dir__is safer, it can exactly find all of the attribute that can be get withobject.__getattribute__. So I think that we can change the way by using this way.Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
__dir__#139950__dir__(GH-139950) #145827__dir__(GH-139950) (GH-145827) #145833