Skip to content

Commit 814a8c1

Browse files
author
hartsantler
committed
fixed __setitem__
1 parent 1e43d3a commit 814a8c1

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

pythonscript/python_to_pythonjs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ def visit_Assign(self, node):
526526
# XXX: support only one target for subscripts
527527
target = node.targets[0]
528528
if isinstance(target, Subscript):
529-
code = "get_attribute(get_attribute('%s', '__setitem__'), '__call__')([%s, %s], JSObject())"
529+
code = "get_attribute(get_attribute(%s, '__setitem__'), '__call__')([%s, %s], JSObject())"
530530
code = code % (self.visit(target.value), self.visit(target.slice.value), self.visit(node.value))
531531
writer.write(code)
532532

tests/test_dict.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,21 @@
1010
print( d['a'] )
1111
print( d['b'] )
1212
print( len(d) )
13-
#d['a'] = 'hello'
14-
#d['b'] = 'world'
15-
#print( d['a'] )
16-
#print( d['b'] )
17-
#print( len(d) )
13+
print( d )
14+
15+
d['a'] = 'hello'
16+
d['b'] = 'world'
17+
print( d['a'] )
18+
print( d['b'] )
19+
print( len(d) )
1820

1921

2022
l = {'x':3, 'y':4}
2123
print( l['x'] )
2224
print( l['y'] )
25+
l['x'] = 'XXX'
26+
print( l['x'] )
27+
print( len(l) )
2328

2429
</script>
2530
</head>

0 commit comments

Comments
 (0)