Re: List to string

2007-03-20 Thread Hendrik van Rooyen
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote: On Tue, 20 Mar 2007 13:01:36 +0100, Bruno Desthuilliers wrote: 8< --- confusion about left and right It gets worse. When you work on a lathe, a "right hand cutting tool" has its cutting edge on the left... And the worse part is th

Re: List to string

2007-03-20 Thread Josh Bloom
That's pretty funny :) On 3/20/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote: On Tue, 20 Mar 2007 13:01:36 +0100, Bruno Desthuilliers wrote: > Steven D'Aprano a écrit : >> On Mon, 19 Mar 2007 13:11:09 +0100, Bruno Desthuilliers wrote: >> >>> There's no "cast" in Python. It would make no sens i

Re: List to string

2007-03-20 Thread Steven D'Aprano
On Tue, 20 Mar 2007 13:01:36 +0100, Bruno Desthuilliers wrote: > Steven D'Aprano a écrit : >> On Mon, 19 Mar 2007 13:11:09 +0100, Bruno Desthuilliers wrote: >> >>> There's no "cast" in Python. It would make no sens in a dynamically >>> typed language, where type informations belong to the LHS of

Re: List to string

2007-03-20 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : > On Mon, 19 Mar 2007 13:11:09 +0100, Bruno Desthuilliers wrote: > >> There's no "cast" in Python. It would make no sens in a dynamically >> typed language, where type informations belong to the LHS of a binding, >> not the RHS. > > Surely you have left and right mixed

Re: List to string

2007-03-19 Thread Steven D'Aprano
On Mon, 19 Mar 2007 13:11:09 +0100, Bruno Desthuilliers wrote: > There's no "cast" in Python. It would make no sens in a dynamically > typed language, where type informations belong to the LHS of a binding, > not the RHS. Surely you have left and right mixed up? x = 1 x = None x = "spam" x = [

Re: List to string

2007-03-19 Thread Hitesh
On Mar 19, 8:11 am, Bruno Desthuilliers wrote: > Hitesh a écrit : > > > On Mar 18, 12:28 am, "Hitesh" <[EMAIL PROTECTED]> wrote: > >> Hi, > > >> I've a list like this.. > >> str1 = ['this is a test string inside list'] > > >> I am doing it this way. > > >> for s in str1: > >> temp_s = s > >>

Re: List to string

2007-03-19 Thread Bruno Desthuilliers
Hitesh a écrit : > On Mar 18, 12:28 am, "Hitesh" <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I've a list like this.. >> str1 = ['this is a test string inside list'] >> >> I am doing it this way. >> >> for s in str1: >> temp_s = s >> print temp_s Why this useless temp_s var ? >> >> Any better

Re: List to string

2007-03-17 Thread Steven D'Aprano
On Sat, 17 Mar 2007 21:28:56 -0700, Hitesh wrote: > > Hi, > > I've a list like this.. > str1 = ['this is a test string inside list'] That's a bad name for the variable. It's called "str1" but it is a list. > I am doing it this way. > > for s in str1: > temp_s = s > print temp_s That

Re: List to string

2007-03-17 Thread Hitesh
On Mar 18, 12:28 am, "Hitesh" <[EMAIL PROTECTED]> wrote: > Hi, > > I've a list like this.. > str1 = ['this is a test string inside list'] > > I am doing it this way. > > for s in str1: > temp_s = s > print temp_s > > Any better suggestions? > > Thank you, > hj I want to cast value of a lis

List to string

2007-03-17 Thread Hitesh
Hi, I've a list like this.. str1 = ['this is a test string inside list'] I am doing it this way. for s in str1: temp_s = s print temp_s Any better suggestions? Thank you, hj -- http://mail.python.org/mailman/listinfo/python-list

Re: How to convert this list to string?

2006-10-18 Thread Jia Lu
Thank you very much. I memoed all you views. :) -- http://mail.python.org/mailman/listinfo/python-list

Re: How to convert this list to string?

2006-10-18 Thread Ron Adam
Jia Lu wrote: > Hi all > > I have a list like: > list > [1, 2, 3] list[1:] > [2, 3] > > I want to get a string "2 3" > str(list[1:]) > '[2, 3]' > > How can I do that ? > > thanks Just to be different from the other suggestions... >>> a = [1, 2, 3] >>> str(a[1:]).strip('[]'

Re: How to convert this list to string?

2006-10-18 Thread Fredrik Lundh
Jia Lu wrote: > Hi all > > I have a list like: > list > [1, 2, 3] list[1:] > [2, 3] > > I want to get a string "2 3" > str(list[1:]) > '[2, 3]' > > How can I do that ? http://effbot.org/zone/python-list.htm#printing -- http://mail.python.org/mailman/listinfo/python-l

Re: How to convert this list to string?

2006-10-18 Thread Travis E. Oliphant
Jia Lu wrote: > Hi all > > I have a list like: > list > [1, 2, 3] list[1:] > [2, 3] > > I want to get a string "2 3" > str(list[1:]) > '[2, 3]' > > How can I do that ? > " ".join(str(x) for x in list) -Travis -- http://mail.python.org/mailman/listinfo/python-list

Re: How to convert this list to string?

2006-10-18 Thread Theerasak Photha
On 18 Oct 2006 00:20:50 -0700, Jia Lu <[EMAIL PROTECTED]> wrote: > I want to get a string "2 3" > > >>> str(list[1:]) > '[2, 3]' > > How can I do that ? ' '.join(str(i) for i in list[1:]) -- Theerasak -- http://mail.python.org/mailman/listinfo/python-list

How to convert this list to string?

2006-10-18 Thread Jia Lu
Hi all I have a list like: >>> list [1, 2, 3] >>> list[1:] [2, 3] I want to get a string "2 3" >>> str(list[1:]) '[2, 3]' How can I do that ? thanks -- http://mail.python.org/mailman/listinfo/python-list