range of characters?
Peter Otten
__peter__ at web.de
Tue Dec 16 14:13:05 EST 2003
Batista, Facundo wrote:
> Bud P. Bruegger wrote:
>
> #- I suppose there should be an elegant way of getting a range
> #- of characters
> #- as in
> #-
> #- range('A', 'Z')
>
> Python 2.2.3 (#1, Jun 18 2003, 16:30:09)
> [GCC 3.2.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import string
>>>> string.letters[26:]
> 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
>
> . Facundo
I smell danger:
>>> import locale as lo
>>> lo.setlocale(lo.LC_ALL, "")
'LC_CTYPE=de_DE at euro;LC_NUMERIC=de_DE at euro;LC_TIME=de_DE at euro;LC_COLLATE=C;LC_MONETARY=de_DE at euro;LC_MESSAGES=de_DE at euro;LC_PAPER=de_DE at euro;LC_NAME=de_DE at euro;LC_ADDRESS=de_DE at euro;LC_TELEPHONE=de_DE at euro;LC_MEASUREMENT=de_DE at euro;LC_IDENTIFICATION=de_DE at euro'
>>> import string
>>> print string.letters[26:]
šµžœßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿABCDEFGHIJKLMNOPQRSTUVWXYZŠŽŒŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ
Probably not what you expected :-(
But this should always work:
>>> string.ascii_uppercase
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
>>> print string.uppercase
ABCDEFGHIJKLMNOPQRSTUVWXYZŠŽŒŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ
Peter
More information about the Python-list
mailing list