Re: shorten this: if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:

2008-06-25 Thread Nick Craig-Wood
Guilherme Polo [EMAIL PROTECTED] wrote: Let me post another one, and longer: if ord(somechar) in range(ord('A'), ord('Z') + 1) + range(ord('a'), ord('z') + 1): ... That is very inefficient! Every time it is run it creates two lists then joins them then throws the whole lot away!

shorten this: if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:

2008-06-24 Thread cirfu
if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz: cant i write something like: if char in [A-Za-z]: ? -- http://mail.python.org/mailman/listinfo/python-list

Re: shorten this: if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:

2008-06-24 Thread Brian Victor
cirfu wrote: if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz: cant i write something like: if char in [A-Za-z]: Either of the following should do what you want, without resorting to regular expressions: import string if char in string.letters: or if char.isalpha(): --

Re: shorten this: if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:

2008-06-24 Thread [EMAIL PROTECTED]
On 24 juin, 20:32, cirfu [EMAIL PROTECTED] wrote: if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz: cant i write something like: if char in [A-Za-z]: Nope. But there are other solutions. Here are two: # 1 import string if char in string.letters: print yay # 2 import re

Re: shorten this: if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:

2008-06-24 Thread Guilherme Polo
On Tue, Jun 24, 2008 at 3:47 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On 24 juin, 20:32, cirfu [EMAIL PROTECTED] wrote: if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz: cant i write something like: if char in [A-Za-z]: Nope. But there are other solutions. Here are

Re: shorten this: if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:

2008-06-24 Thread Walter Cruz
another way: import string if char in string.ascii_letters: print('hello buddy!') []'s - Walter -- http://mail.python.org/mailman/listinfo/python-list

Re: shorten this: if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:

2008-06-24 Thread MRAB
On Jun 24, 7:59 pm, Guilherme Polo [EMAIL PROTECTED] wrote: On Tue, Jun 24, 2008 at 3:47 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On 24 juin, 20:32, cirfu [EMAIL PROTECTED] wrote: if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz: cant i write something like: if

Re: shorten this: if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:

2008-06-24 Thread John Machin
On Jun 25, 4:32 am, cirfu [EMAIL PROTECTED] wrote: if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz: cant i write something like: if char in [A-Za-z]: You can write that if you want to, but it's equivalent to if char in zaZa]-[: i.e. it doesn't do what you want. This gives

Re: shorten this: if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:

2008-06-24 Thread s0suk3
On Jun 24, 5:36 pm, John Machin [EMAIL PROTECTED] wrote: On Jun 25, 4:32 am, cirfu [EMAIL PROTECTED] wrote: if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz: cant i write something like: if char in [A-Za-z]: You can write that if you want to, but it's equivalent to if

Re: shorten this: if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:

2008-06-24 Thread John Machin
On Jun 25, 9:06 am, [EMAIL PROTECTED] wrote: On Jun 24, 5:36 pm, John Machin [EMAIL PROTECTED] wrote: On Jun 25, 4:32 am, cirfu [EMAIL PROTECTED] wrote: if char in ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz: cant i write something like: if char in [A-Za-z]: You can