Re: computing with characters



En Wed, 30 Apr 2008 05:00:26 -0300, Arnaud Delobelle <arnodel@xxxxxxxxxxxxxx> escribió:

"Gabriel Genellina" <gagsl-py2@xxxxxxxxxxxx> writes:

En Wed, 30 Apr 2008 04:19:22 -0300, SL <ni@xxxxxxx> escribió:

"Lutz Horn" <lutz.georg.horn@xxxxxxxxxxxxxx> schreef in bericht
news:mailman.360.1209537877.12834.python-list@xxxxxxxxxxxxx

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 couldnt find it anywhere in the docs.

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. (Or is there any other reason? what's wrong with "a".ord()
or str.from_ordinal(65))?


Not a reason, but doesn't ord() word with unicode as well?

Yes, so ord() could be an instance method of both str and unicode, like upper(), strip(), and all of them...
And str.from_ordinal(n)==chr(n), unicode.from_ordinal(n)==unichr(n)

--
Gabriel Genellina

.



Relevant Pages

  • Re: Problem in accessing files with unicode fonts.
    ... garner you more and about as quick responses, ... I'd advise you to read the docs for `unicode`, ... The reason being the intensity of the problem and time factor. ... a result the getfileattributes function is failing to recognise that file ...
    (comp.lang.python)
  • Re: Is Chris Hills a troll?
    ... All the C99 additions can go (see elsethread for my very short list of ... exceptions). ... Complete, thorough Unicode handling. ... Its lack is a major reason people pick other languages for writing apps ...
    (comp.lang.c)
  • Re: MFC(VC6) Application Localization from French to Chinese(RPC)
    ... I didn't think you could do a Unicode .RC file ... I even tried the application in Chinese OS. ... the reason is because I am using mutiple .rc files in one ... display like "??". ...
    (microsoft.public.vc.mfc)
  • Re: a unicode conversion issue in a file opening command
    ... Did you define the symbol UNICODE also? ... Why use char*? ... explained why it failed, and better still, the text string that represents the reason it ... MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)
  • Re: Unicode in Delphi/VCL (yet again)
    ... > The use of Unicode has been successful. ... > Deployment on Win32 has been successful. ... do u mean no reason NOT to switch? ...
    (borland.public.delphi.non-technical)