Open
Description
I wrote this:
DIGITS = {str(i): i for i in range(10)} | dict(zip('ABCDEF', range(10, 16)))
In Visual Studio Code, I see this refactoring popping up:
Remove Redundant Constructor in Dict Union
The suggested fix was:
{str(i): i for i in range(10)} | zip('ABCDEF', range(10, 16))
Which raises the following error:
TypeError: unsupported operand type(s) for |: 'dict' and 'zip'
This is a bug, please fix this.
Side note:
Although I changed my code to the following:
DIGITS = {f'{i:X}' for i in range(16)}
I know I can use int(h, 16)
, but I need to get hexadecimal numbers out of a string that starts with hexadecimal but contains other things, I do it like this:
DIGITS = {f'{i:X}': i for i in range(16)}
i = n = 0
while (d := DIGITS.get(line[i])) is not None:
n = (n << 4) | d
i += 1
Metadata
Metadata
Assignees
Labels
No labels