We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 40c1272 commit 7347755Copy full SHA for 7347755
1 file changed
tests/basics/class_super_closure.py
@@ -0,0 +1,18 @@
1
+# test that no-arg super() works when self is closed over
2
+
3
+class A:
4
+ def __init__(self):
5
+ self.val = 4
6
+ def foo(self):
7
+ # we access a member of self to check that self is correct
8
+ return list(range(self.val))
9
+class B(A):
10
11
+ # self is closed over because it's referenced in the list comprehension
12
+ # and then super() must detect this and load from the closure cell
13
+ return [self.bar(i) for i in super().foo()]
14
+ def bar(self, x):
15
+ return 2 * x
16
17
+print(A().foo())
18
+print(B().foo())
0 commit comments