Re: computing with characters

2008-05-11 Thread Gabriel Genellina
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

Re: computing with characters

2008-05-06 Thread cokofreedom
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

Re: computing with characters

2008-05-06 Thread Boris Borcic
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

Re: computing with characters

2008-05-01 Thread George Sakkis
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

Re: computing with characters

2008-05-01 Thread Duncan Booth
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]>

Re: computing with characters

2008-04-30 Thread George Sakkis
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

Re: computing with characters

2008-04-30 Thread Terry Reedy
"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

Re: computing with characters

2008-04-30 Thread Mel
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

Re: computing with characters

2008-04-30 Thread Carl Banks
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

Re: computing with characters

2008-04-30 Thread George Sakkis
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

Re: computing with characters

2008-04-30 Thread Torsten Bronger
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

Re: computing with characters

2008-04-30 Thread Diez B. Roggisch
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

Re: computing with characters

2008-04-30 Thread Duncan Booth
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

Re: computing with characters

2008-04-30 Thread Torsten Bronger
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

Re: computing with characters

2008-04-30 Thread Marc 'BlackJack' Rintsch
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

Re: computing with characters

2008-04-30 Thread Marco Mariani
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

Re: computing with characters

2008-04-30 Thread Torsten Bronger
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

Re: computing with characters

2008-04-30 Thread Duncan Booth
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

Re: computing with characters

2008-04-30 Thread Gabriel Genellina
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

Re: computing with characters

2008-04-30 Thread Torsten Bronger
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)

Re: computing with characters

2008-04-30 Thread SL
"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.

Re: computing with characters

2008-04-30 Thread SL
"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

Re: computing with characters

2008-04-30 Thread Arnaud Delobelle
"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

Re: computing with characters

2008-04-30 Thread Gabriel Genellina
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

Re: computing with characters

2008-04-30 Thread SL
"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()

Re: computing with characters

2008-04-30 Thread Kam-Hung Soh
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";>

Re: computing with characters

2008-04-29 Thread Lutz Horn
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')

Re: computing with characters

2008-04-29 Thread Gary Herron
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-

computing with characters

2008-04-29 Thread SL
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