Walther Neuper wrote: > loving Java (oo)
Don't mind, weirder things have happened http://wiki.muenster.org/index.php/Schwan > as well as SML (fun) I use to practice both of them > separately. > Now, with Python I would like to combine 'oo.extend()' with 'functional > map': > > Python 2.4.4 (#2, Oct 22 2008, 19:52:44) > [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> def reverse_(list): > ... """list.reverse() returns None; reverse_ returns the reversed > list""" > ... list.reverse() > ... return list > ... > >>> ll = [[11, 'a'], [33, 'b']] > >>> l = ll[:] # make a copy ! > >>> l = map(reverse_, l[:]) # make a copy ? > >>> ll.extend(l) > >>> print("ll=", ll) > ('ll=', [['a', 11], ['b', 33], ['a', 11], ['b', 33]]) > > But I expected to get ... > ('ll=', [[11, 22], [33, 44], [22, 11], [44, 33]]) > ... how would that elegantly be achieved with Python ? Sorry, I cannot infer the pattern. How would you do that at all? Peter -- http://mail.python.org/mailman/listinfo/python-list