Re: Operators as functions

2004-12-21 Thread Fredrik Lundh
Anders Andersson wrote: > I want to concatinate (I apologize for bad English, but it is not my native > language) fast det stavas iofs inte konkatinera på svenska heller ;-) > a list of strings to a string. > And here is the questions: What to replace "concatinating function" with? Can > I in

Re: Operators as functions

2004-12-21 Thread Anders Andersson
Peter Hansen wrote: Anders Andersson wrote: I want to concatinate (I apologize for bad English, but it is not my native language) a list of strings to a string. I could use (I think): s = "" map(lambda x: s.append(x), theList) But I want to do something like (I think that the code above is clumsy

Re: Operators as functions

2004-12-21 Thread Anders Andersson
Steve Holden wrote: Anders Andersson wrote: Hello I want to concatinate (I apologize for bad English, but it is not my native language) a list of strings to a string. I could use (I think): s = "" map(lambda x: s.append(x), theList) But I want to do something like (I think that the code above is

Re: Operators as functions

2004-12-20 Thread Peter Nuttall
On Monday 20 Dec 2004 22:44, Anders Andersson wrote: > Hello > > I want to concatinate (I apologize for bad English, but it is not my > native language) a list of strings to a string. I could use (I think): > > s = "" > map(lambda x: s.append(x), theList) > > But I want to do something like (I thin

Re: Operators as functions

2004-12-20 Thread Steven Bethard
Peter Hansen wrote: However, none of this is considered the best approach these days, with the advent of list comprehensions and generator expressions. Here's the old approach (shown above) and the shiny new modern Pythonic approach (requires Python 2.4): >>> theList = range(10) >>> import operat

Re: Operators as functions

2004-12-20 Thread Peter Hansen
Anders Andersson wrote: I want to concatinate (I apologize for bad English, but it is not my native language) a list of strings to a string. I could use (I think): s = "" map(lambda x: s.append(x), theList) But I want to do something like (I think that the code above is clumsy): s = reduce("conca

Re: Operators as functions

2004-12-20 Thread Steve Holden
Anders Andersson wrote: Hello I want to concatinate (I apologize for bad English, but it is not my native language) a list of strings to a string. I could use (I think): s = "" map(lambda x: s.append(x), theList) But I want to do something like (I think that the code above is clumsy): s = reduce(