[issue46422] Why do we need `dis.Positions`?
Batuhan Taskaya
report at bugs.python.org
Wed Jan 19 03:52:55 EST 2022
Batuhan Taskaya <isidentical at gmail.com> added the comment:
The initial aim of the dis.Positions was to provide an interface like AST nodes. So you could do
for instr in dis.Bytecode(source):
print("located in: ", instr.positions.lineno)
instead of
for instr in dis.Bytecode(source):
if instr.positions:
lineno = instr.positions[0]
else:
lineno = None
print("located in: ", lineno)
I think this is a bug that we are not currently using it, I'd say we should use it properly and go with option 2.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46422>
_______________________________________
More information about the Python-bugs-list
mailing list