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? 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/
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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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. ...
|
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?...
|
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,...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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...
| |