diferent answers with isalpha()

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Jul 12 22:23:05 EDT 2007


En Thu, 12 Jul 2007 21:05:42 -0300, <nuno at salgado.ws> escribió:

> Hi,
>
> I have python with sys.version_info = (2, 4, 4, 'final', 0)
>
> In Idle when I do print 'á'.isalpha() I get True. When I make and
> execute a script file with the same code I get False.
>
> Why do I have diferent answers ?

Do you include an encoding directive at the top? (If you omit it you get a  
warning in 2.4 and an error in 2.5)

Try this:

import unicodedata
print unicodedata.name(u'á')

 from IDLE and from inside a script. You should get "LATIN SMALL LETTER A  
WITH ACUTE"; if not, Python thinks your terminal uses a different encoding  
than the actual one.

-- 
Gabriel Genellina




More information about the Python-list mailing list