From: David Flanagan Date: 2007-02-06T12:28:12+09:00 Subject: Re: String.ord Yukihiro Matsumoto wrote: > Hi, > > In message "Re: String.ord" > on Tue, 6 Feb 2007 07:03:05 +0900, David Flanagan writes: > > |Does anyone (Matz?) know why the (new in 1.9) String.ord method is > |restricted to one-character Strings? > > I just followed Python convention here. Ah ha. I don't know Python well enough, or maybe I would have realized that. It still seems to me that there ought to be a way to get the 1.8 behavior in a single method call rather than having to call [] and then call ord on the result. If you don't want to modify ord to accept an index, Would you consider ordAt(x) or codepoint(x) or something like that? David >>>> ord("a") > 97 >>>> ord("abc") > Traceback (most recent call last): > File "", line 1, in ? > TypeError: ord() expected a character, but string of length 3 found > > Besides that, raising exception may help us find bugs earlier. > Any opinion? > > matz. > >