Is there a simple function to generate a list like ['a', 'b', 'c', ... 'z']?
Michael Bentley
michael at jedimindworks.com
Mon Apr 9 15:07:22 EDT 2007
On Apr 9, 2007, at 6:30 AM, Duncan Booth wrote:
> Michael Bentley <michael at jedimindworks.com> wrote:
>
>>
>> On Apr 9, 2007, at 3:29 AM, 人è¨è½æ¥æ¯å¤©æ¶¯ï¼ææ天涯ä¸
>> è§å®¶ wrote:
>>
>>> Is there a simple function to generate a list like ['a', 'b',
>>> 'c', ...
>>> 'z']? The range() just can generate the numeric list.
>>
>>
>> import string
>> list(string.lowercase)
>>
> Be careful here. If you change locale that will return all lowercase
> letters not just 'a' to 'z'. For example:
>
>>>> import locale, string
>>>> locale.setlocale(locale.LC_ALL, '')
> 'English_United Kingdom.1252'
>>>> print string.lowercase
> abcdefghijklmnopqrstuvwxyzªµºßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ
>
Thanks, Duncan -- that would have eventually bitten me.
More information about the Python-list
mailing list