f

#### Is there a simple function to generate a list like ['a', 'b', 'c', ... 'z']?

```Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']?   The range() just can generate the numeric list.

```
 0
kelvin.you (40)
4/9/2007 8:29:24 AM
comp.lang.python 77058 articles. 6 followers.

10 Replies
1101 Views

Similar Articles

[PageSpeed] 6

```On Apr 9, 2007, at 3:29 AM, =E4=BA=BA=E8=A8=80=E8=90=BD=E6=97=A5=E6=98=AF=E5=
=A4=A9=E6=B6=AF=EF=BC=8C=E6=9C=9B=E6=9E=81=E5=A4=A9=E6=B6=AF=E4=B8=8D=20
=E8=A7=81=E5=AE=B6 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)

```
 0
michael8264 (111)
4/9/2007 8:35:26 AM
```人言落日是天涯，望极天涯不见家 schrieb:
> Is there a simple function to generate a list like ['a', 'b', 'c', ...
> 'z']?   The range() just can generate the numeric list.

There is:
[ chr(i) for i in range(97, 123) ]

Thomas
```
 0
4/9/2007 8:39:20 AM
```T24gQXByIDksIDQ6MzXCoHBtLCBNaWNoYWVsIEJlbnRsZXkgPG1pY2guLi5AamVkaW1pbmR3b3Jr
cy5jb20+IHdyb3RlOgo+IE9uIEFwciA5LCAyMDA3LCBhdCAzOjI5IEFNLCDkurroqIDokL3ml6Xm
mK/lpKnmtq/vvIzmnJvmnoHlpKnmtq/kuI0KPgo+IOingeWutiB3cm90ZToKPiA+IElzIHRoZXJl
IGEgc2ltcGxlIGZ1bmN0aW9uIHRvIGdlbmVyYXRlIGEgbGlzdCBsaWtlIFsnYScsICdiJywgJ2Mn
LCAuLi4KPiA+ICd6J10/IMKgIFRoZSByYW5nZSgpIGp1c3QgY2FuIGdlbmVyYXRlIHRoZSBudW1l
cmljIGxpc3QuCj4KPiBpbXBvcnQgc3RyaW5nCj4gbGlzdChzdHJpbmcubG93ZXJjYXNlKQoKVGhh
bmtzIGEgbG90IQo=

```
 0
kelvin.you (40)
4/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chr,range(65,91))

/Martin

```
 0
4/9/2007 10:05:41 AM
```Michael Bentley <michael@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���������������������������������������
>>>
```
 0
duncan.booth (1734)
4/9/2007 11:30:41 AM
```On Mon, 09 Apr 2007 01:43:11 -0700, 7stud wrote:

>> Is there a simple function to generate a list like ['a', 'b', 'c', ...
>> 'z']? � The range() just can generate the numeric list.
>
> Not very simple, but how about a list comprehension:
>
> import string
>
> lst = [char for char in string.letters[:26] ]
> print lst

Anytime you write a list comp like [x for x in thing] that should be a
warning that you shouldn't be writing a list comp.

lst = list(string.letters[:26])

--
Steven.

```
 0
steve88 (536)
4/9/2007 1:08:06 PM
```    Thomas> [ chr(i) for i in range(97, 123) ]

Or with fewer magic numbers:

[chr(i) for i in range(ord('a'), ord('z')+1)]

Skip
```
 0
skip133 (2030)
4/9/2007 1:59:49 PM
```On Apr 9, 2007, at 6:30 AM, Duncan Booth wrote:

> Michael Bentley <michael@jedimindworks.com> wrote:
>
>>
>> On Apr 9, 2007, at 3:29 AM, =E4=BA=BA=E8=A8=80=E8=90=BD=E6=97=A5=E6=98=AF=
=E5=A4=A9=E6=B6=AF=EF=BC=8C=E6=9C=9B=E6=9E=81=E5=A4=A9=E6=B6=AF=E4=B8=8D
>> =E8=A7=81=E5=AE=B6 wrote:
>>
>>> Is there a simple function to generate a list like ['a', 'b', =20
>>> '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=83=9A=9C=9E=AA=B5=BA=DF=E0=E1=E2=E3=E4=E5=E6=E7=
=E8=E9=EA=EB=EC=ED=EE=EF=F0=F1=F2=F3=F4=F5=F6=F8=F9=FA=FB=FC=FD=FE=FF
>

Thanks, Duncan -- that would have eventually bitten me.

```
 0
michael8264 (111)
4/9/2007 7:07:22 PM

Similar Artilces:

'is not' or '!='
A newbie question to you; what is the difference between statements like: if x is not None: and if x != None: Without any context, which one should be preferred? IMHO, the latter is more readable. On 2014-08-18 21:35, ElChino wrote: > A newbie question to you; what is the difference between statements > like: > if x is not None: > and > if x != None: > > Without any context, which one should be preferred? > IMHO, the latter is more readable. > "x == y" tells you whether x and y refer to objects that are equal. "x is y" tells you whether x and y actually refer to the same object. In the case of singletons like None (there's only one None object), it's better to use "is". "ElChino" <elchino@cnn.cn>: > A newbie question to you; what is the difference between statements > like: > if x is not None: > and > if x != None: Do the following: take two \$10 bills. Hold one bill in the left hand, hold the other bill in the right hand. Now, the bill in the left hand "is not" the bill in the right hand. However, the bill in the left hand "==" the bill in the right hand. > Without any context, which one should be preferred? > IMHO, the latter is more readable. In almost all cases, both tests would result in the same behavior. However, the "is not" test is conceptually the correct one since you want...

A function with 'and' , 'not' , 'null' , 'car' and 'cdr'
What's this ? (defun enigma (x) (and (not (null x)) (or (null (car x)) (enigma (cdr x))))) "I suppose I should learn Lisp, but it seems so foreign." - Paul Graham, Nov 1983 On Wed, Oct 07 2015, CAI GENGYANG wrote: > What's this ? > > > (defun enigma (x) > (and (not (null x)) > (or (null (car x)) > (enigma (cdr x))))) Bad taste? It returns T if the list X contains nil as an element. It would be clearer to write (some #'null x). Helmut CAI GENGYANG ...

'a'..'z'
Is it possible to achieve something like this? switch (mystring.charAt(0)) { case 'a'..'z': // do something break; } "cruster" <cruster@gmail.com> wrote in message news:1151319731.988814.326200@m73g2000cwd.googlegroups.com... > Is it possible to achieve something like this? > > switch (mystring.charAt(0)) { > case 'a'..'z': > // do something > break; > } > There are times when an if statement may be more appropriate ;) Sorry - java is not VB :) -- LTP :) cruster schreef: > Is it possible to achieve somethi...

'''''''''''''The Running Update/Append Queries Using VBA code Ordeal'''''''''''''' #2

if str_mo not in ('','.') and str_da not in ('','.') and str_yy not in ('','.') Any shorter ?
Hi, there. =20 I'm just curious if it ever dawned on anybody how to abbreviate this line : if str_mo not in ('','.') and str_da not in ('','.') and str_yy not in ('','.')=20 =20 Igor Kurbeko Clinical Programmer Analyst 678 336 4328 ikurbeko@atherogenics.com =20 no brain no pain =20 how about: if not (str_mo in ('','.') or str_da in ('','.') or str_yy in ('','.')) OR if not (missing(str_mo) or missing(str_da) or missing(str_yy)) Eric On 22 Oct 03 21:13:37 GMT, ikurbeko@ATHER...

error: expected '=', ',', ';', 'asm' or '__attrib
Hi I'm trying to compile an ADC Driver & come acrosss the following error. I've no experience writing drivers before, and hence have no clue how to fix it. Hope someone out there has encountered the problem & suggesst a fix for the same. The Error is I get is : qadc.c: At top level: qadc.c:97: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'qadc_read' make: *** [qadc.o] Error 1 [root@localhost qadc]# ########################################################################### ADC Driver Code ##...

difference between ',' and 'a,'
Small question. In gforth is there a difference between the words ',' and 'a,'? I'm thinking not, so perhaps another question, why have both ',' and 'a,'? Thanks Should be the same, in gforth: see , : , here cell allot ! ; ok see a, : , here cell allot ! ; ok On Friday, January 9, 2015 at 5:46:04 AM UTC-8, beeflo wrote: > Small question. In gforth is there a difference between the words ',' and 'a,'? > > I'm thinking not, so perhaps another question, why have both ',' and 'a,'? > > Thanks beeflo <beeflobill@gmail.com> writes: >Small question. In gforth is there a difference between the words ',' and 'a,'? > >I'm thinking not, so perhaps another question, why have both ',' and 'a,'? In Gforth itself, there is no difference. In Gforth's cross compiler, "a," is there for addresses, and "," is there for other cells; addresses can then be relocated when loading the image. - anton -- M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html New standard: http://www.forth200x.org/forth200x.html EuroForth 2014: http://www.euroforth.org/ef14/ ...

Override 'and' and 'or'
Is it possible to override 'and' and/or 'or'? I cannot find a special method for it... __and__ and __rand__ and __or__ and __ror__ are for binary manipulation... any proposals? Have marvelous sunday, Marco Dekker <m.aschwanden@gmail.com> wrote: > Is it possible to override 'and' and/or 'or'? I cannot find a special > method for it... __and__ and __rand__ and __or__ and __ror__ are for > binary manipulation... any proposals? If you want to customize the truth value testing you have to implement __nonzero__ " __nonzero__( self) Call...

'!' vs. '.'
Is there an advantage to using the '!' notation to represent form/ control relationships? (eg. Me!text1 vs Me.text1) I am currently using the '.' notation exclusively (for code completion in the VB Editor), but much of the high-quality code that I've seen (in Duane Hookom's Query-by-Form db, for example) uses the other. Here's one opinion for you: http://doc.advisor.com/doc/05352 robert.waters wrote: >Is there an advantage to using the '!' notation to represent form/ >control relationships? (eg. Me!text1 vs Me.text1) > >I am currently using the '.' notation exclusively (for code completion >in the VB Editor), but much of the high-quality code that I've seen >(in Duane Hookom's Query-by-Form db, for example) uses the other. -- HTH - RuralGuy (RG for short) acXP WinXP Pro Please post back to this forum so all may benefit. Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/200704/1 Here's my \$0.02 worth on this. I tend to copy the notation style and naming conventions that I see being used in the Help files. That would be Me![text1] for a control on a form. I am of the belief that this notation explicitly refers to a control itself rather than a field in the form's recordset. Here's an example: I have a parts inventory app that uses a "Line" code, which is usually a 3-character abbreviation for a brand name, and is the na...

Does '!=' equivelent to 'is not'
I'm a bit confusing about whether "is not" equivelent to "!=" if a != b: ... if a is not b: ... What's the difference between "is not" and "!=" or they are the same thing? pirata wrote: > I'm a bit confusing about whether "is not" equivelent to "!=" > > if a != b: > ... > > if a is not b: > ... > > > What's the difference between "is not" and "!=" or they are the same thing? No, they are not the same thing. == and != test to see if the *value* of two variables are the same. Like so: >>> a = 'hello world' >>> b = 'hello world' >>> a == b True a and b both have the value of 'hello world', so they are equal is and is not, however, do not test for value equivalence, they test for object identity. In other words, they test to see if the object the two variables reference are the same object in memory, like so: >>> a is b False a and b are assigned to two different objects that happen to have the same value, but nevertheless there are two separate 'hello world' objects in memory, and therefore you cannot say that a *is* b Now look at this: >>> c = d = 'hello world' >>> c == d True >>> c is d True In this case, they are again the same value, but now the is test also shows that they are the same *object* as well, because...

['a', 'b'][True] results 'b' But how?
Hi, Can any one please tell me how is the following code is working? ['a','b'] is a list of string, and [True] is list of boolean value. How is it making effect....? <code Python24> >>> ['a','b] [True] 'b' >>> ['a','b'] [False] 'a' >>> ['a','b']['some_string' == r'some_string'] 'b' >>> ['a','b']['some_string' == r'somestring'] 'a' <code> Thanks in advance, regards, kath. In this case, [True] and [False...

logical to 'on' / 'off'
Hi, is there a function implemented doing this conversion? my Problem is, that I want to use the following code: set(handles.edit_curr_trq_sl,'Enable',get(hObject,'Value')) where get(hObject,'Value') gives the state of a checkbox thank you! function [str]=tf2oo(logic) switch logic case 0 str='off'; case 1 str='on'; end%switch end%function tf2oo() while i do not know a built in function, I use my own:) meisterbartsch wrote: > > > function [str]=tf2oo(logic) > switch logic > case 0 > str='off'; &g...

Difference between 'is' and '=='
Hey guys, this maybe a stupid question, but I can't seem to find the result anywhere online. When is the right time to use 'is' and when should we use '=='? Thanks alot~ mwql: >Hey guys, this maybe a stupid question, but I can't seem to find the >result anywhere online. When is the right time to use 'is' and when >should we use '=='? http://docs.python.org/ref/comparisons.html -- Ren� Pijlman mwql wrote: > Hey guys, this maybe a stupid question, but I can't seem to find the > result anywhere online. When is the right time to ...

We Are Selling The Nextel I930 For Just \$130usd'''''''''''
Dear Customer We have all brands of Mobile Phones,Ipods,Sidekicks,Nextel phone,Laptops for sell at cheap an affordable prices, they ranges from Nokia/Samsung/LG/Son Ericsson/Motorola/Alcatel/panasonic With Bluetooth, al Brands and Models of Nextel Phones, we want you to get bac to us with your quote so that we can begin a good busines relationship. Note they are all Brand New T2 Euro specs unlocked, no operator logo, come in thei original sealed box, With 1 year international warrant from the manufacturer, English & Spanish manual, Finlan made We want to assure you that you will never r...

Re: if str_mo not in ('','.') and str_da not in ('','.') and str_yy not in ('','.') Any shorter ? #2
Igor, There are many ways to make it more concise, however the parsimony is likely to be achieved at the expense of clarity. For instance, the expressions length ( input (mm||dd||yy, \$10.) ) > 2 length ( compress(mm||dd||yy, ' .') ) > 2 and like might be somewhat shorter than the original, but they will execute slower, and their intent is far less eminent. Since it appears that you are trying to validate the components of a date, maybe it is not a worthless idea to try the date informat conforming to the mask you are testing. Say if all the pieces are 2-digit, the expression input (mm||dd||yy, ?? mmddyy6.) will return a missing value for the case you are testing and also if any irregularities in the input value that prevent it from being interpreted as a valid date should be found. And if you want a note in the log to alert you about it, leave one of the question marks off. Kind regards, ================= Paul M. Dorfman Jacksonville, FL ================= >From: Igor Kurbeko <ikurbeko@ATHEROGENICS.COM> >Reply-To: Igor Kurbeko <ikurbeko@ATHEROGENICS.COM> >To: SAS-L@LISTSERV.UGA.EDU >Subject: if str_mo not in ('','.') and str_da not in ('','.') and str_yy > not in ('','.') Any shorter ? >Date: Wed, 22 Oct 2003 17:13:37 -0400 > >Hi, there. > > > >I'm just curious if it ever dawned on anybody how to abbreviate this >line : > >if ...

if ('A:B:C' =~ /:(.*?)\$/) then why the heck is \$1 'B:C' and not just 'C'
To repeat the title, in case it is munged by Google Groups: if ('A:B:C' =~ /:(.*?)\$/) then why the heck is \$1 'B:C' and not just 'C' I've been developing with perl for years; but even simple things in it still sometimes throw up surprises. The regexp /:(.*?)\$/ is anchored on the right by \$, then comes a non- greedy match which, AIUI, is the "shortest string it can get away with", preceded by a colon. So I would expect this to pick up just the "C", as it does with /([^:]*)\$/. Am I assuming/doing something silly? It is frid...

We Are Selling The Samsung D500 For Just \$189usd'''''''''
Dear Customer We have all brands of Mobile Phones,Ipods,Sidekicks,Nextel phone,Laptops for sell at cheap an affordable prices, they ranges from Nokia/Samsung/LG/Son Ericsson/Motorola/Alcatel/panasonic With Bluetooth, al Brands and Models of Nextel Phones, we want you to get bac to us with your quote so that we can begin a good busines relationship. Note they are all Brand New T2 Euro specs unlocked, no operator logo, come in thei original sealed box, With 1 year international warrant from the manufacturer, English & Spanish manual, Finlan made We want to assure you that you will never r...

(a==b) ? 'Yes' : 'No'
Hi, how can I write the popular C/JAVA syntax in Python? Java example: return (a==b) ? 'Yes' : 'No' My first idea is: return ('No','Yes')[bool(a==b)] Is there a more elegant/common python expression for this? On Mar 30, 11:40=A0am, gentlestone <tibor.b...@hotmail.com> wrote: > Hi, how can I write the popular C/JAVA syntax in Python? > > Java example: > =A0 =A0 return (a=3D=3Db) ? 'Yes' : 'No' > > My first idea is: > =A0 =A0 return ('No','Yes')[bool(a=3D=3Db)] > > Is there a more elegan...

Re: if str_mo not in ('','.') and str_da not in ('','.') and str_ yy not in ('','.') Any shorter ? #4
Igor, Without robust error checking: %macro check ( vars , values , op = in /* not in */, con = and /* or */ ) ; %local i w ; %let i = 1 ; %let w = %scan(&vars,&i) ; %do %while ( %length ( &w ) > 0 ) ; %if &i > 1 %then &con ; &w &op &values %let i = %eval ( &i + 1 ) ; %let w = %scan(&vars,&i) ; %end ; %mend check ; option mprint ; data w ; retain x y z "a" r " " s t "a" a b 99 c . ; if %check( x y z , ('','.'), op = not in ) then put &qu...

Re: if str_mo not in ('','.') and str_da not in ('','.') and str_ yy not in ('','.') Any shorter ? #3
> From: Igor Kurbeko [mailto:ikurbeko@ATHEROGENICS.COM] > I'm just curious if it ever dawned on anybody > how to abbreviate this line : > > if str_mo not in ('','.') > and str_da not in ('','.') > and str_yy not in ('','.') %*in autoexec:; %Let Blank = Blank; %Let Invalid = Invalid; %*in aFormat; PROC Format; value \$StrValu %*somevalues = 'ok'; '','.' = "&Blank." %* other = "&Invalid."; ; %*in Program; if put(Str_...

Removing the letters 't' 'i' 'x' and 'y'
Im having trouble with figuring out how to write a function which will remove the letters 't' 'i' 'x' and 'y' from any input string in matlab. for example modstr(pixy) should result in ans = 'p' or modstr(picture) should result in ans = 'pcure' if anyone could offer any help or hints i would really appreciate it. Thank You >> modstr=@(s) s(~ismember(s,'tixy')) modstr = @(s)s(~ismember(s,'tixy')) >> modstr('picture') ans = pcure % Bruno ...

Avoid 'int', 'long' and 'short'...
.... #include <cstdint> instead! /Flibble On 26/06/2015 20:39, Mr Flibble wrote: > ... #include <cstdint> instead! > > /Flibble you mean using int16_t? why is that? int is the fastest integer so why would i use something else? On 26/06/2015 21:31, JiiPee wrote: > On 26/06/2015 20:39, Mr Flibble wrote: >> ... #include <cstdint> instead! >> >> /Flibble > > you mean using int16_t? why is that? > int is the fastest integer so why would i use something else? Because 'int' is both unsafe and non-portable. If yo...

Why is 'None' not assignable but 'True'/'False' are?
In Python 2.4.1: >>> None = 99 SyntaxError: assignment to None >>> True = 99 >>> False = 99 >>> True == False True ----------------------- So why is 'None' special? Rodney Maxwell <rodney.maxwell@gmail.com> wrote: > In Python 2.4.1: > > >>> None = 99 > SyntaxError: assignment to None > >>> True = 99 > >>> False = 99 > >>> True == False > True > ----------------------- > So why is 'None' special? A legacy/backwards compatibility issue: None has been there 'foreve...

Calling 'foo.c' or 'foo2.c' from my 'main_code.c'
Hello. I don't know if following is possible. I've got 'main_code.c': ............................ char * another_code; another_code = "foo.c"; ............................ I've got 'foo.c': ............................ #include <stdio.h> int main() { printf ("Hello world from 'foo.c'!\n"); return 0; } ............................ I would like to call 'foo.c' main function from 'main_code.c'. Is this possible? Thank you very much and best regards. Francesco Moi <francescomoi@europe.com> scribbled the ...

Web resources about - Is there a simple function to generate a list like ['a', 'b', 'c', ... 'z']? - comp.lang.python

Resources last updated: 3/15/2016 9:51:28 AM