Re: Concatenating Strings

2015-04-09 Thread Chris Angelico
On Fri, Apr 10, 2015 at 5:19 AM, Ben Bacarisse wrote: > Chris Angelico writes: > >> On Fri, Apr 10, 2015 at 4:46 AM, Ben Finney >> wrote: >>> Travis Griggs writes: >>> Here’s 3 examples: if k + ‘_@‘ in documents: timeKey = k + ‘_@‘ historyKey = th

Re: Concatenating Strings

2015-04-09 Thread Ben Bacarisse
Chris Angelico writes: > On Fri, Apr 10, 2015 at 4:46 AM, Ben Finney > wrote: >> Travis Griggs writes: >> >>> Here’s 3 examples: >>> >>> if k + ‘_@‘ in documents: >>> >>> timeKey = k + ‘_@‘ >>> >>> historyKey = thingID + ‘_’ + k >> >> In addition to the other responses, I'll point

Re: Concatenating Strings

2015-04-09 Thread Chris Angelico
On Fri, Apr 10, 2015 at 4:46 AM, Ben Finney wrote: > Travis Griggs writes: > >> Here’s 3 examples: >> >> if k + ‘_@‘ in documents: >> >> timeKey = k + ‘_@‘ >> >> historyKey = thingID + ‘_’ + k > > In addition to the other responses, I'll point out a different issue: > > Your client is

Re: Concatenating Strings

2015-04-09 Thread Ben Finney
Travis Griggs writes: > Here’s 3 examples: > > if k + ‘_@‘ in documents: > > timeKey = k + ‘_@‘ > > historyKey = thingID + ‘_’ + k In addition to the other responses, I'll point out a different issue: Your client is composing messages that munge your text. Ensure you post only the e

Re: Concatenating Strings

2015-04-09 Thread Andrew Farrell
I am under the impression that using format() is the canonically "right way to do it". It is certainly more readable than using ''.join() and is more semantically specific than string addition. On Thu, Apr 9, 2015 at 1:35 PM, Chris Angelico wrote: > On Fri, Apr 10, 2015 at 4:29 AM, Travis Griggs

Re: Concatenating Strings

2015-04-09 Thread Chris Angelico
On Fri, Apr 10, 2015 at 4:44 AM, Andrew Farrell wrote: > I am under the impression that using format() is the canonically "right way > to do it". It is certainly more readable than using ''.join() and is more > semantically specific than string addition. Depends what you're doing. Sometimes it's

Re: Concatenating Strings

2015-04-09 Thread Chris Angelico
On Fri, Apr 10, 2015 at 4:29 AM, Travis Griggs wrote: > > if k + ‘_@‘ in documents: > > timeKey = k + ‘_@‘ > > historyKey = thingID + ‘_’ + k > > I’m curious where others lean stylistically with this kind of thing. I see > *at least* 2 other alternatives: > So few? I'd just use strin

Concatenating Strings

2015-04-09 Thread Travis Griggs
I was doing some maintenance now on a script of mine… I noticed that I compose strings in this little 54 line file multipole times using the + operator. I was prototyping at the time I wrote it and it was quick and easy. I don’t really care for the way they read. Here’s 3 examples: if k + ‘

Re: concatenating strings

2006-12-15 Thread Caleb Hattingh
Hi Erich If you're going to be doing a lot of string substitution, you should look at the Templating support in the library: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/304005 and (a little bit fancier): http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/335308 Regards Caleb

Re: concatenating strings

2006-12-15 Thread Erich Pul
thank you, i just plainly overlooked it ; ) now it works -- http://mail.python.org/mailman/listinfo/python-list

Re: concatenating strings

2006-12-15 Thread Laurent Pointal
EHC a écrit : > hello! > > since i am a py noob, please bear with me ; ) > > how is it possible to concat a string and an integer in a > print-command? i've tried > > print "This robot is named %s. The current speed setting is %d, and %s > has a lifetime of %d" % (self.name , self.speed , self.n

concatenating strings

2006-12-15 Thread EHC
hello! since i am a py noob, please bear with me ; ) how is it possible to concat a string and an integer in a print-command? i've tried print "This robot is named %s. The current speed setting is %d, and %s has a lifetime of %d" % (self.name , self.speed , self.name) as well as print "This ro

Re: Concatenating strings

2006-06-30 Thread Steven Bethard
John Henry wrote: > I have a list of strings (some 10,000+) and I need to concatenate them > together into one very long string. The obvious method would be, for > example: > > alist=["ab","cd","ef",.,"zzz"] > blist = "" > for x in alist: >blist += x > > But is there a cleaner and faster

Re: Concatenating strings

2006-06-30 Thread Robert Kern
John Henry wrote: > Sorry if this is a dumb question. > > I have a list of strings (some 10,000+) and I need to concatenate them > together into one very long string. The obvious method would be, for > example: > > alist=["ab","cd","ef",.,"zzz"] > blist = "" > for x in alist: >blist += x

Concatenating strings

2006-06-30 Thread John Henry
Sorry if this is a dumb question. I have a list of strings (some 10,000+) and I need to concatenate them together into one very long string. The obvious method would be, for example: alist=["ab","cd","ef",.,"zzz"] blist = "" for x in alist: blist += x But is there a cleaner and faster wa

Concatenating strings

2006-06-30 Thread John Henry
Sorry if this is a dumb question. I have a list of strings (some 10,000+) and I need to concatenate them together into one very long string. The obvious method would be, for example: alist=["ab","cd","ef",.,"zzz"] blist = "" for x in alist: blist += x But is there a cleaner and faster wa