Re: String building using join

2011-01-04 Thread Arnaud Delobelle
gervaz ger...@gmail.com writes: Hi all, I would like to ask you how I can use the more efficient join operation in a code like this: class Test: ... def __init__(self, v1, v2): ... self.v1 = v1 ... self.v2 = v2 ... def prg(l): ... txt = ... for x in l:

Re: String building using join

2011-01-03 Thread Alexander Gattin
Hello, On Sun, Jan 02, 2011 at 10:11:50AM -0800, Alex Willmer wrote: def prg3(l): return '\n'.join([str(x) for x in l if x]) just one fix (one fix one fix one fix): return '\n'.join([str(x) for x in l if x is not None]) -- With best regards, xrgtn --

Re: String building using join

2011-01-03 Thread Kushal Kumaran
On Mon, Jan 3, 2011 at 3:07 AM, gervaz ger...@gmail.com wrote: On 2 Gen, 19:14, Emile van Sebille em...@fenx.com wrote: snip class Test:       def __init__(self, v1, v2):           self.v1 = v1           self.v2 = v2 t1 = Test(hello, None) t2 = Test(None, ciao) t3 = Test(salut, hallo)

Re: String building using join

2011-01-02 Thread gervaz
On 31 Dic 2010, 16:43, Emile van Sebille em...@fenx.com wrote: On 12/31/2010 7:22 AM gervaz said... Hi all, I would like to ask you how I can use the more efficient join operation in a code like this: class Test: ...     def __init__(self, v1, v2): ...         self.v1 = v1 ...  

Re: String building using join

2011-01-02 Thread Emile van Sebille
On 1/2/2011 9:43 AM gervaz said... On 31 Dic 2010, 16:43, Emile van Sebilleem...@fenx.com wrote: On 12/31/2010 7:22 AM gervaz said... Hi all, I would like to ask you how I can use the more efficient join operation in a code like this: class Test: ... def __init__(self, v1, v2):

Re: String building using join

2011-01-02 Thread Alex Willmer
On Sunday, January 2, 2011 5:43:38 PM UTC, gervaz wrote: Sorry, but it does not work def prg3(l): ... return \n.join([x for x in l if x]) ... prg3(t) Traceback (most recent call last): File stdin, line 1, in module File stdin, line 2, in prg3 TypeError: sequence item 0:

Re: String building using join

2011-01-02 Thread gervaz
On 2 Gen, 19:14, Emile van Sebille em...@fenx.com wrote: On 1/2/2011 9:43 AM gervaz said... On 31 Dic 2010, 16:43, Emile van Sebilleem...@fenx.com  wrote: On 12/31/2010 7:22 AM gervaz said... Hi all, I would like to ask you how I can use the more efficient join operation in a code

Re: String building using join

2011-01-02 Thread gervaz
On 2 Gen, 22:37, gervaz ger...@gmail.com wrote: On 2 Gen, 19:14, Emile van Sebille em...@fenx.com wrote: On 1/2/2011 9:43 AM gervaz said... On 31 Dic 2010, 16:43, Emile van Sebilleem...@fenx.com  wrote: On 12/31/2010 7:22 AM gervaz said... Hi all, I would like to ask you how I

String building using join

2010-12-31 Thread gervaz
Hi all, I would like to ask you how I can use the more efficient join operation in a code like this: class Test: ... def __init__(self, v1, v2): ... self.v1 = v1 ... self.v2 = v2 ... def prg(l): ... txt = ... for x in l: ... if x.v1 is not None: ...

Re: String building using join

2010-12-31 Thread Emile van Sebille
On 12/31/2010 7:22 AM gervaz said... Hi all, I would like to ask you how I can use the more efficient join operation in a code like this: class Test: ... def __init__(self, v1, v2): ... self.v1 = v1 ... self.v2 = v2 ... def prg(l): ... txt = ... for x in l: ...