En Tue, 06 May 2008 08:16:55 -0300, <[EMAIL PROTECTED]> escribió:
> I tend to do ", ".join("%s" % e for e in item)
>
> Is there any difference between this and str()?
Use the timeit module to measure performance:
C:\TEMP>python -m timeit "for i in xrange(1): str(i)"
10 loops, best of 3: 81.8
On May 6, 12:22 pm, Boris Borcic <[EMAIL PROTECTED]> wrote:
> Duncan Booth wrote:
> > Torsten Bronger <[EMAIL PROTECTED]> wrote:
>
> >> The biggest ugliness though is ",".join(). No idea why this should
> >> be better than join(list, separator=" "). Besides, ",".join(u"x")
> >> yields an unicode
Duncan Booth wrote:
Torsten Bronger <[EMAIL PROTECTED]> wrote:
The biggest ugliness though is ",".join(). No idea why this should
be better than join(list, separator=" "). Besides, ",".join(u"x")
yields an unicode object. This is confusing (but will probably go
away with Python 3).
It is o
On May 1, 3:36 am, Duncan Booth <[EMAIL PROTECTED]> wrote:
> George Sakkis <[EMAIL PROTECTED]> wrote:
> > On Apr 30, 5:06 am, Torsten Bronger <[EMAIL PROTECTED]>
> > wrote:
> >> Hallöchen!
>
> >> SL writes:
> >> > "Gabriel Genellina" <[EMAIL PROTECTED]> schreef in bericht
> >> >news:[EMAIL PROTECT
George Sakkis <[EMAIL PROTECTED]> wrote:
> On Apr 30, 5:06 am, Torsten Bronger <[EMAIL PROTECTED]>
> wrote:
>> Hallöchen!
>>
>> SL writes:
>> > "Gabriel Genellina" <[EMAIL PROTECTED]> schreef in bericht
>> >news:[EMAIL PROTECTED]
>>
>> >> En Wed, 30 Apr 2008 04:19:22 -0300, SL <[EMAIL PROTECTED]>
On Apr 30, 3:53 pm, Mel <[EMAIL PROTECTED]> wrote:
> George Sakkis wrote:
> > def join(iterable, sep=' ', encode=str):
> > return sep.join(encode(x) for x in iterable)
>
> Actually
>
> return encode(sep).join(encode(x) for x in iterable)
>
> lest you get TypeErrors for non-string separa
"Marco Mariani" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
| Torsten Bronger wrote:
|
| > However, join() is really bizarre. The list rather than the
| > separator should be the leading actor.
|
| No, because join must work with _any sequence_, and there is no
| "sequence" type
George Sakkis wrote:
> def join(iterable, sep=' ', encode=str):
> return sep.join(encode(x) for x in iterable)
Actually
return encode(sep).join(encode(x) for x in iterable)
lest you get TypeErrors for non-string separators.
Mel.
--
http://mail.python.org/mailman/listinfo/p
On Apr 30, 6:47 am, Duncan Booth <[EMAIL PROTECTED]> wrote:
> Torsten Bronger <[EMAIL PROTECTED]> wrote:
> > The biggest ugliness though is ",".join(). No idea why this should
> > be better than join(list, separator=" "). Besides, ",".join(u"x")
> > yields an unicode object. This is confusing (b
On Apr 30, 5:06 am, Torsten Bronger <[EMAIL PROTECTED]>
wrote:
> Hallöchen!
>
> SL writes:
> > "Gabriel Genellina" <[EMAIL PROTECTED]> schreef in bericht
> >news:[EMAIL PROTECTED]
>
> >> En Wed, 30 Apr 2008 04:19:22 -0300, SL <[EMAIL PROTECTED]> escribió: And
> >> that's a very reasonable place to
Hallöchen!
Diez B. Roggisch writes:
>> However, join() is really bizarre. The list rather than the
>> separator should be the leading actor.
>
> Certainly *not*! This would be the way ruby does it, and IMHO it
> does not make sense to add join as a string-processing related
> method/functionalit
However, join() is really bizarre. The list rather than the
separator should be the leading actor.
Certainly *not*! This would be the way ruby does it, and IMHO it does
not make sense to add join as a string-processing related
method/functionality to a general purpose sequence type. And as ot
Torsten Bronger <[EMAIL PROTECTED]> wrote:
> However, join() is really bizarre. The list rather than the
> separator should be the leading actor.
Do you mean the list, or do you mean the list/the tuple/the dict/the
generator/the file and anything else which just happens to be an iterable
seque
Hallöchen!
Marco Mariani writes:
> Torsten Bronger wrote:
>
>> However, join() is really bizarre. The list rather than the
>> separator should be the leading actor.
>
> No, because join must work with _any sequence_, and there is no
> "sequence" type to put the join method on.
No, but for the s
On Wed, 30 Apr 2008 13:12:05 +0200, Torsten Bronger wrote:
> However, join() is really bizarre. The list rather than the
> separator should be the leading actor.
You mean any iterable should be the leading actor, bacause `str.join()`
works with any iterable. And that's why it is implemented *on
Torsten Bronger wrote:
However, join() is really bizarre. The list rather than the
separator should be the leading actor.
No, because join must work with _any sequence_, and there is no
"sequence" type to put the join method on.
This semantic certainly sets python apart from many other lang
Hallöchen!
Duncan Booth writes:
> Torsten Bronger <[EMAIL PROTECTED]> wrote:
>
>> The biggest ugliness though is ",".join(). No idea why this should
>> be better than join(list, separator=" "). Besides, ",".join(u"x")
>> yields an unicode object. This is confusing (but will probably go
>> away
Torsten Bronger <[EMAIL PROTECTED]> wrote:
> The biggest ugliness though is ",".join(). No idea why this should
> be better than join(list, separator=" "). Besides, ",".join(u"x")
> yields an unicode object. This is confusing (but will probably go
> away with Python 3).
It is only ugly because
En Wed, 30 Apr 2008 05:00:26 -0300, Arnaud Delobelle
<[EMAIL PROTECTED]> escribió:
"Gabriel Genellina" <[EMAIL PROTECTED]> writes:
En Wed, 30 Apr 2008 04:19:22 -0300, SL <[EMAIL PROTECTED]> escribió:
"Lutz Horn" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
So just for co
Hallöchen!
SL writes:
> "Gabriel Genellina" <[EMAIL PROTECTED]> schreef in bericht
> news:[EMAIL PROTECTED]
>
>> En Wed, 30 Apr 2008 04:19:22 -0300, SL <[EMAIL PROTECTED]> escribió: And
>> that's a very reasonable place to search; I think chr and ord are
>> builtin functions (and not str methods)
"Gabriel Genellina" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
En Wed, 30 Apr 2008 04:19:22 -0300, SL <[EMAIL PROTECTED]> escribió:
And that's a very reasonable place to search; I think chr and ord are
builtin functions (and not str methods) just by an historical accident.
"Arnaud Delobelle" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
"Gabriel Genellina" <[EMAIL PROTECTED]> writes:
En Wed, 30 Apr 2008 04:19:22 -0300, SL <[EMAIL PROTECTED]> escribió:
"Lutz Horn" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
So just for compl
"Gabriel Genellina" <[EMAIL PROTECTED]> writes:
> En Wed, 30 Apr 2008 04:19:22 -0300, SL <[EMAIL PROTECTED]> escribió:
>
>> "Lutz Horn" <[EMAIL PROTECTED]> schreef in bericht
>> news:[EMAIL PROTECTED]
>>>
>>> So just for completion, the solution is:
>>>
>> chr(ord('a') + 1)
>>> 'b'
>>
>> thank
En Wed, 30 Apr 2008 04:19:22 -0300, SL <[EMAIL PROTECTED]> escribió:
"Lutz Horn" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
So just for completion, the solution is:
chr(ord('a') + 1)
'b'
thanks :) I'm a beginner and I was expecting this to be a member of
string so I
"Lutz Horn" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
Hi,
2008/4/30 Gary Herron <[EMAIL PROTECTED]>:
SL wrote:
> How can I compute with the integer values of characters in python?
> Like 'a' + 1 equals 'b' etc
You can get an integer value from a character with the ord()
On Wed, 30 Apr 2008 16:13:17 +1000, SL <[EMAIL PROTECTED]> wrote:
How can I compute with the integer values of characters in python?
Like 'a' + 1 equals 'b' etc
Try: ord('a')
See also: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65117
--
Kam-Hung Soh http://kamhungsoh.com/blog";>
Hi,
2008/4/30 Gary Herron <[EMAIL PROTECTED]>:
> SL wrote:
> > How can I compute with the integer values of characters in python?
> > Like 'a' + 1 equals 'b' etc
>
> You can get an integer value from a character with the ord() function.
So just for completion, the solution is:
>>> chr(ord('a')
SL wrote:
How can I compute with the integer values of characters in python?
Like
'a' + 1 equals 'b' etc
--
http://mail.python.org/mailman/listinfo/python-list
You can get an integer value from a character with the ord() function.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-
How can I compute with the integer values of characters in python?
Like
'a' + 1 equals 'b' etc
--
http://mail.python.org/mailman/listinfo/python-list
29 matches
Mail list logo