473,395 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Generate alphabet?

In Haskell I can do [1..10] for range(1,11) and ['a'..'z'] for a list
of the alphabet.

Is there a way in Python to generate chars?
Aug 22 '08 #1
4 11248
On Fri, 22 Aug 2008 15:02:19 -0700 (PDT), ssecorp wrote:
In Haskell I can do [1..10] for range(1,11) and ['a'..'z'] for a list
of the alphabet.

Is there a way in Python to generate chars?
It's not actually about generating anything, but why should
one generate something if it's accessible anyway:

import string
print string.letters

--
Regards,
Wojtek Walczak,
http://tosh.pl/gminick/
Aug 22 '08 #2
ssecorp wrote:
In Haskell I can do [1..10] for range(1,11) and ['a'..'z'] for a list
of the alphabet.

Is there a way in Python to generate chars?
How about:

def haskellrange(sc,ec):
if type(sc) is int:
for ii in range(sc,ec):
yield ii
else:
for ii in range(ord(sc),ord(ec)+1):
yield chr(ii)
for jj in haskellrange(1,10): jj

for jj in haskellrange('a','z'): jj
Add salt to taste...

Emile

Aug 22 '08 #3
On Fri, Aug 22, 2008 at 6:02 PM, ssecorp <ci**********@gmail.comwrote:
.['a'..'z'] for a list of the alphabet.

Is there a way in Python to generate chars?

Not as nice as in Haskell (or other languages), but:

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

Regards
Aug 22 '08 #4
On Sat, Aug 23, 2008 at 6:02 AM, ssecorp <ci**********@gmail.comwrote:
In Haskell I can do [1..10] for range(1,11) and ['a'..'z'] for a list
of the alphabet.

Is there a way in Python to generate chars?
how about:
>>import string
','.join(string.ascii_lowercase)
'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y ,z'
>>>

--
Best Regards,
Leo Jay
Aug 23 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: one | last post by:
greetings i am just wondering if some expert here can either show me how to do this or point me to the right direction (url... i want to use c# to generate a list of alphabet e.g A B C ... AA...
2
by: Peter R | last post by:
Hi, Probably this question was asked before, but what is the algorithm to generate all combinations based on N numbers? For example, for 3 elements = {1,2,3}, I'd like to generate a list of...
5
by: Stefan Krah | last post by:
Hello, I am currently writing code where it is convenient to convert char to int . The conversion function relies on a character set with contiguous alphabets. int set_mesg(Key *key, char...
12
by: one | last post by:
greetings i am just wondering if some expert here can either show me how to do this or point me to the right direction (url... i want to use c# to generate a list of alphabet e.g A B C ... AA...
8
by: Jack Addington | last post by:
I want to scroll through the alphabet in order to scroll some data to the closest name that starts with a letter. If the user hits the H button then it should scroll to the letter closest to H. ...
31
by: Joe Smith | last post by:
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789" " " "!#%^&*()-_" "+=~\|;:\'" "\"{},.<>/\?" "\a\b\f\n\r\t\v\\" Do the above string literals comprise an alphabet for C?...
28
by: Rob Cowie | last post by:
Hi all, I wish to generate a sequence of the form 'aaa', 'aab', aac'.... 'aba', 'abb', 'abc' etc. all the way to 'zzz'. How would you construct a generator to acheive this? A simple,...
8
by: dohyohdohyoh | last post by:
I have a programming question to generate an ordered list of alphanumeric strings of length 4. two alphabets rest numberst, etc. EG 0000-9999 then A000-Z999 then AA00 to ZZ99 then AAA0 - ZZZ9...
20
by: geebanga88 | last post by:
HI i have a method that is supose to store the alphabet in an array however dont think that it is being added to the array. public static void GetAlphabet (char alphabet) { int...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.