Variable depth of nesting

Robin Becker robin at jessikat.fsnet.co.uk
Wed Feb 7 07:28:35 EST 2001


In article <g0k872soog.fsf at scumbag.ecs.soton.ac.uk>, Jacek Generowicz
<jmg at ecs.soton.ac.uk> writes
for the variable length list comprehension I tried

>>> def vlc(L):
...     v = ''
...     f = ''
...     for i in xrange(len(L)):
...             v += ',x%d'%i
...             f += ' for x%d in L[%d]' % (i,i)
...     return eval('[(%s) %s]' % (v[1:],f))
... 

and it seems to work
-- 
Robin Becker



More information about the Python-list mailing list