Bug with lists of pairs of lists and append()

Gabriel Zachmann zachREMOVE at MEin.tu-clausthal.de
Mon Oct 1 11:33:55 CEST 2007


> I'm using list(l) to copy the list, Tero uses l[:], but the idea is
> the same.
> 

Thanks a lot for your response and the hint.

> But do you just want all proper partitions of lst? Then this is much
> simpler:
> lst = [0, 1, 2]
> s = [(lst[:i], lst[i:]) for i in range(1, len(lst))]


Ah, thanks a lot for that nice line of code!
Python keeps astonishing me ;-)

Cheers,
Gabriel.

-- 
______________________________________________________________
Life is so constructed that the event does not, cannot,
will not match the expectation.             (Charlotte Bronte)
______________________________________________________________
  zach in.tu-clausthal.de      __@/'    www.gabrielzachmann.org
______________________________________________________________



More information about the Python-list mailing list