Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in Python only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
Python
Generate alphabet?
Collapse
This topic is closed.
X
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
ssecorp
#1
Generate alphabet?
Aug 22 '08, 10:05 PM
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?
Wojtek Walczak
#2
Aug 22 '08, 10:15 PM
Re: Generate alphabet?
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,
Oferta sprzedaży domeny: tosh.pl
http://tosh.pl/gminick/
Cena domeny: 4999 PLN (do negocjacji). Możliwość kupna na raty od 624.88 PLN miesięcznie. Oferta sprzedaży znajduje się w serwisie Aftermarket.pl, największej giełdzie domen internetowych w Polsce.
Comment
Post
Cancel
Emile van Sebille
#3
Aug 22 '08, 10:25 PM
Re: Generate alphabet?
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),o rd(ec)+1):
yield chr(ii)
for jj in haskellrange(1, 10): jj
for jj in haskellrange('a ','z'): jj
Add salt to taste...
Emile
Comment
Post
Cancel
Medardo Rodriguez (Merchise Group)
#4
Aug 22 '08, 10:25 PM
Re: Generate alphabet?
On Fri, Aug 22, 2008 at 6:02 PM, ssecorp <circularfunc@g mail.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
Comment
Post
Cancel
Leo Jay
#5
Aug 23 '08, 02:35 PM
Re: Generate alphabet?
On Sat, Aug 23, 2008 at 6:02 AM, ssecorp <circularfunc@g mail.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(stri ng.ascii_lowerc ase)
'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
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment