using "*" to make a list of lists with repeated (and independent) elements

88888 Dihedral dihedral88888 at googlemail.com
Sat Sep 29 14:50:52 EDT 2012


On Sunday, September 30, 2012 1:19:22 AM UTC+8, Ian wrote:
> On Sat, Sep 29, 2012 at 11:01 AM, 88888 Dihedral
> 
> <dihedral88888 at googlemail.com> wrote:
> 
> >
> 
> > Don't you get it why I avoided the lambda one liner as a functon.
> 
> >
> 
> > I prefer the def way with a name chosen.
> 
> 
> 
> Certainly, but the Bresenham line algorithm is O(n), which is why it
> 
> is so superior to quicksort that is O(n log n).  Of course you might
> 
> try the Capo Ferro optimization, but I find that Thibault cancels out
> 
> Capo Ferro, don't you?

OK! I'll illustrate the lazy aspect of the python interpreter furthermore.

a=[1,2,3]
b=[a]*4 # different from a sliced copy as [list(a)]*4
print b
a[1]=4
print b
#-----
a=666 # type morphed
print b 



More information about the Python-list mailing list