gervaz 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:
>
On Mon, Jan 3, 2011 at 3:07 AM, gervaz wrote:
> On 2 Gen, 19:14, Emile van Sebille wrote:
>>
>>
>> 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")
>> t =
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
--
http://mail.python.org/mailman/
On 2 Gen, 22:37, gervaz wrote:
> On 2 Gen, 19:14, Emile van Sebille wrote:
>
>
>
>
>
> > On 1/2/2011 9:43 AM gervaz said...
>
> > > On 31 Dic 2010, 16:43, Emile van Sebille wrote:
> > >> On 12/31/2010 7:22 AM gervaz said...
>
> > >>> Hi all, I would like to ask you how I can use the more efficie
On 2 Gen, 19:14, Emile van Sebille wrote:
> On 1/2/2011 9:43 AM gervaz said...
>
>
>
>
>
> > On 31 Dic 2010, 16:43, Emile van Sebille 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:
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 "", line 1, in
> File "", line 2, in prg3
> TypeError: sequence item 0: e
On 1/2/2011 9:43 AM gervaz said...
On 31 Dic 2010, 16:43, Emile van Sebille 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
On 31 Dic 2010, 16:43, Emile van Sebille 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
>
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:
...
John Salerno wrote:
> Out of curiosity, is there any kind of equivalent in Python to the
> StringBuilder class in C#? Here's a quick description from the .NET
> documentation:
>
> "This class represents a string-like object whose value is a mutable
> sequence of characters. The value is said to
John Salerno wrote:
> Out of curiosity, is there any kind of equivalent in Python to the
> StringBuilder class in C#?
You can just append each string to a list and call "".join(list) on the
list. Here is a mock-up StringBuilder class:
class StringBuilder:
def __init__(self): self.strlis
John Salerno <[EMAIL PROTECTED]> wrote:
>Out of curiosity, is there any kind of equivalent in Python to the
>StringBuilder class in C#? Here's a quick description from the .NET
>documentation:
>
>"This class represents a string-like object whose value is a mutable
>sequence of characters. The v
John Salerno wrote:
> Out of curiosity, is there any kind of equivalent in Python to the
> StringBuilder class in C#?
Yes, usually you use StringIO/cStringIO for this. It works for those
situations where you just want to append to a string as you build it.
The alternative is just to build up
On 4/3/06, John Salerno <[EMAIL PROTECTED]> wrote:
> Out of curiosity, is there any kind of equivalent in Python to the
> StringBuilder class in C#? Here's a quick description from the .NET
> documentation:
>
> "This class represents a string-like object whose value is a mutable
> sequence of chara
14 matches
Mail list logo