Re: building strings from variables

2006-10-07 Thread Gal Diskin
First of all - thanks for all the replies. (Sorry for my slowness in answering, but I wrote this message from work, just before leaving for the weekend.) I found a couple of posts that might be of interest: Regarding speed I found a similar discussion in this newsgroup with interesting results: ht

Re: building strings from variables

2006-10-07 Thread Gal Diskin
Matthew Warren wrote: > > -Original Message- > > From: > > [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] > > rg] On Behalf Of Gal Diskin > > Sent: 05 October 2006 16:01 > > To: python-list@python.org > > Subject: building strings from

Re: building strings from variables

2006-10-05 Thread Neil Cerutti
On 2006-10-06, MonkeeSage <[EMAIL PROTECTED]> wrote: > wesley chun wrote: >> from the performance standpoint, i believe that #4 (list join) >> from scott is the fastest. #1 (string formatting) is next >> preferred only because #3 (string concat) is the worst [think >> "realloc()"]. #2 is useful fo

Re: building strings from variables

2006-10-05 Thread MonkeeSage
Ps. For readability you can also roll your own sprintf function: def format(s, *args, **kwargs): if args: return s % args elif kwargs: return s % kwargs else: return s s = 'I like %s and %s.' print format(s, 'ham', 'cheese') s = 'I like %(b)s and %(c)s.' print format(s, b='butt

Re: building strings from variables

2006-10-05 Thread MonkeeSage
wesley chun wrote: > from the performance standpoint, i believe that #4 (list join) from > scott is the fastest. #1 (string formatting) is next preferred only > because #3 (string concat) is the worst [think "realloc()"]. #2 is > useful for when you have users who aren't as comfortable with #1. I

Re: building strings from variables

2006-10-05 Thread wesley chun
> Following a discussion with an associate at work about various ways to build strings from variables in python, I'd like to hear your opinions and preferred methods. from the performance standpoint, i believe that #4 (list join) from scott is the fastest. #1 (string formatting) is next preferred

Re: building strings from variables

2006-10-05 Thread Scott David Daniels
Gal Diskin wrote: > Following a discussion with an associate at work about various ways to > build strings from variables in python, I'd like to hear your opinions > and preferred methods. The methods we discussed are: > 1. some_string = "cd %s ; %s %d %s %s" % ( working_dir, ssh_cmd, > some_coun

Re: building strings from variables

2006-10-05 Thread Rainy
Gal Diskin wrote: > Following a discussion with an associate at work about various ways to > build strings from variables in python, I'd like to hear your opinions > and preferred methods. The methods we discussed are: > 1. some_string = "cd %s ; %s %d %s %s" % ( working_dir, ssh_cmd, > some_cou

RE: building strings from variables

2006-10-05 Thread Matthew Warren
> -Original Message- > From: > [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > rg] On Behalf Of Gal Diskin > Sent: 05 October 2006 16:01 > To: python-list@python.org > Subject: building strings from variables > > Following a discussion with an associate

building strings from variables

2006-10-05 Thread Gal Diskin
Following a discussion with an associate at work about various ways to build strings from variables in python, I'd like to hear your opinions and preferred methods. The methods we discussed are: 1. some_string = "cd %s ; %s %d %s %s" % ( working_dir, ssh_cmd, some_count, some_param1, some_param2)