Transcrypt icon indicating copy to clipboard operation
Transcrypt copied to clipboard

problem with del dict['key']

Open jggatc opened this issue 4 years ago • 1 comments

Problem with del dict['key'] using __pragma__('opov')

The del dict['key'] statement works with no pragma, but dictionary key is not removed using __pragma__('opov') or transcrypt -o option. In addition, del dict['key'] using __pragma__('opov') causes a parse error with code minification. The dict.pop('key') method does not have an issue.

test1.py:

d = {'a': 1, 'b': 2, 'c': 3}
del d['c']
print(d)

transcrypt -n test1.py output: {'a': 1, 'b': 2}

test2.py:

__pragma__('opov')
d = {'a': 1, 'b': 2, 'c': 3}
del d['c']
print(d)

transcrypt -n test2.py output: {'a': 1, 'b': 2, 'c': 3}

transcrypt test2.py (with minification) Parse error. Invalid delete operand. Only properties can be deleted. delete getitem (d, 'c');

Environment: Linux Python 3.9.6 Transcrypt 3.9.0 Chrome/Firefox

jggatc avatar Feb 15 '22 18:02 jggatc

Had similar problem with del dict['key'] not working using __pragma__('keycheck') or -kc option. The dict.pop('key') method can be used instead, which is unaffected by either __pragma__('opov') or __pragma__('keycheck').

jggatc avatar Oct 23 '23 23:10 jggatc