Re: python string, best way to concat

2014-08-28 Thread Mark Lawrence
On 28/08/2014 13:08, Roy Smith wrote: In article <63bdccb4-9e34-4e40-b07d-14342e218...@googlegroups.com>, peter wrote: I used to struggle with the concept of ''.join(('hello ','world')) - it seemed so convoluted compared with the intuitive 'hello '+'world', and I could never remember the syn

Re: python string, best way to concat

2014-08-28 Thread Mihamina Rakotomandimby
On 08/28/2014 03:08 PM, Roy Smith wrote: For places where performance doesn't matter, string addition is just fine. The computer works for you. If you're working for the computer, you're doing something wrong. I like this :-) -- https://mail.python.org/mailman/listinfo/python-list

Re: python string, best way to concat

2014-08-28 Thread Roy Smith
In article <63bdccb4-9e34-4e40-b07d-14342e218...@googlegroups.com>, peter wrote: > I used to struggle with the concept of ''.join(('hello ','world')) - it > seemed so convoluted compared with the intuitive 'hello '+'world', and I > could never remember the syntax. Also, for the strings I was

Re: python string, best way to concat

2014-08-28 Thread Chris Angelico
On Thu, Aug 28, 2014 at 6:43 PM, Mark Lawrence wrote: > On 28/08/2014 09:30, peter wrote: >> >> I used to struggle with the concept of ''.join(('hello ','world')) - it >> seemed so convoluted compared with the intuitive 'hello '+'world', and I >> could never remember the syntax. Also, for the str

Re: python string, best way to concat

2014-08-28 Thread Mark Lawrence
On 28/08/2014 09:30, peter wrote: I used to struggle with the concept of ''.join(('hello ','world')) - it seemed so convoluted compared with the intuitive 'hello '+'world', and I could never remember the syntax. Also, for the strings I was generally using the performance penalty was infinites

Re: python string, best way to concat

2014-08-28 Thread peter
I used to struggle with the concept of ''.join(('hello ','world')) - it seemed so convoluted compared with the intuitive 'hello '+'world', and I could never remember the syntax. Also, for the strings I was generally using the performance penalty was infinitesimal, so I was just adding complexit

Re: python string, best way to concat

2014-08-28 Thread Marko Rauhamaa
peter : > Obviously this isn't going to change, but for concatenating short > strings a and b is there any practical reason to avoid a+b? Often, no. The biggest penalty is visual. For example, I would prefer this: "{}/{}".format(prefix, suffix) over prefix + "/" + suffix Really, I wo

Re: python string, best way to concat

2014-08-28 Thread MRAB
On 2014-08-27 23:59, Peter Otten wrote: Tim Chase wrote: On 2014-08-27 23:42, MRAB wrote: How many parameters are there? len(self.param) Make that many placeholders and then join them together with commas: ', '.join(['?'] * len(self.param)) I prefer the clarity of Peter Otten's suggestion

Re: python string, best way to concat

2014-08-27 Thread Peter Otten
Tim Chase wrote: > On 2014-08-27 23:42, MRAB wrote: >> How many parameters are there? len(self.param) >> >> Make that many placeholders and then join them together with commas: >> >> ', '.join(['?'] * len(self.param)) > > I prefer the clarity of Peter Otten's suggestion of > > ', '.join('?'

Re: python string, best way to concat

2014-08-27 Thread Chris Angelico
On Thu, Aug 28, 2014 at 8:44 AM, Tim Chase wrote: > On 2014-08-27 23:42, MRAB wrote: >> How many parameters are there? len(self.param) >> >> Make that many placeholders and then join them together with commas: >> >> ', '.join(['?'] * len(self.param)) > > I prefer the clarity of Peter Otten's sugge

Re: python string, best way to concat

2014-08-27 Thread Tim Chase
On 2014-08-27 23:42, MRAB wrote: > How many parameters are there? len(self.param) > > Make that many placeholders and then join them together with commas: > > ', '.join(['?'] * len(self.param)) I prefer the clarity of Peter Otten's suggestion of ', '.join('?' * len(self.param)) over the mild

Re: python string, best way to concat

2014-08-27 Thread MRAB
On 2014-08-27 21:31, dennisearlev...@gmail.com wrote: Hi, Sorry about the simple question but I am very new to Python. Anyway, I have a function that will be used to call a stored procedure and I need to format the string with the correct number of parameter markers for the ODBC dri

Re: python string, best way to concat

2014-08-27 Thread Peter Otten
dennisearlev...@gmail.com wrote: > > Hi, > > Sorry about the simple question but I am very new to Python. > > Anyway, I have a function that will be used to call a stored procedure > and I need to format the string with the correct number of parameter > markers for the ODBC driver, fa

Re: python string, best way to concat

2014-08-27 Thread Dan Stromberg
On Wed, Aug 27, 2014 at 1:31 PM, wrote: > > Hi, > > Sorry about the simple question but I am very new to Python. > > Anyway, I have a function that will be used to call a stored procedure and > I need to format the string with the correct number of parameter markers for > the ODBC driver,

python string, best way to concat

2014-08-27 Thread dennisearlevans
Hi, Sorry about the simple question but I am very new to Python. Anyway, I have a function that will be used to call a stored procedure and I need to format the string with the correct number of parameter markers for the ODBC driver, fairly standard stuff. What I have works but lo