ernest wrote:

> In this code:
> 
> if set(a).union(b) == set(a): pass
> 
> Does Python compute set(a) twice?

>>> a = "abc"
>>> b = "def"
>>> _set = set
>>> def set(x):
...     print "computing set(%r)" % x
...     return _set(x)
...
>>> if set(a).union(b) == set(a): pass
...
computing set('abc')
computing set('abc')

So yes, set(a) is computed twice.

Peter
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to