- Code: Select all
x = {a, b, c}
while y in x
dosomething
- Code: Select all
while y==a or y==b or y==c
dosomething
i say these two code snippets are (or should be) functionally identical. yes?
x = {a, b, c}
while y in x
dosomething
while y==a or y==b or y==c
dosomething
"""
cobra set-in-or.cobra
"""
class P
def main
.one
.two
print 'done.'
def one
print 'one'
a, b, c = 1, 2, 3
x = {a, b, c}
y = a
trace y, x
while y in x
.doSomething
if y == a, y = b
else, y = .d
trace y, x
print 'done with one'
def two
print 'two'
a, b, c = 1, 2, 3
y = a
trace y, a, b, c
while y==a or y==b or y==c
.doSomething
if y == a, y = b
else, y = .d
trace y, a, b, c
print 'done with two'
def doSomething
pass
def d as int
return 4
class P
def main
.three
print 'done.'
Console.readKey
def three
print 'three'
a, b, c = 1, 2, 3
x = {a, b, c}
trace a, x
a = 4
trace a, x
print 'done with three'
set1 = {1, 2}
x, y = 1, 2
set2 = {x, y}
assert set1 == set2 # equal because contents are the same
assert set1 is not set2 # not the same object
Users browsing this forum: No registered users and 10 guests