Re: [Tutor] unicode: alpha, whitespaces and digits

2013-12-29 Thread eryksun
On Sun, Dec 29, 2013 at 5:58 PM, Steven D'Aprano wrote: > If you want to test for something that a human reader will recognise as > a "whole number", s.isdigit() is probably the best one to use. isdigit() includes decimal digits plus other characters that have a digit value: >>> print u'\N{s

Re: [Tutor] unicode: alpha, whitespaces and digits

2013-12-29 Thread Steven D'Aprano
On Mon, Dec 30, 2013 at 09:58:10AM +1100, Steven D'Aprano wrote: > What gives you that impression? isspace works on Unicode strings too. > > py> ' x'.isspace() > False > py> ''.isspace() > True Oops, the above was copied and pasted from Python 3, which is why there are no u' prefixes. But

Re: [Tutor] unicode: alpha, whitespaces and digits

2013-12-29 Thread Steven D'Aprano
On Sun, Dec 29, 2013 at 02:36:32PM +0100, Ulrich Goebel wrote: > Hallo, > > I have a unicode string s, for example u"abc", u"äöü", u"123" or > something else, and I have to find out wether > > 1. s is not empty and contains only digits (as in u"123", but not in > u"3.1415") > > or > > 2. s is

Re: [Tutor] unicode: alpha, whitespaces and digits

2013-12-29 Thread Dave Angel
On Sun, 29 Dec 2013 19:20:04 +, Mark Lawrence wrote: > 2. s is empty or contains only whitespaces Call strip() on it. If it's now empty, it was whitespace. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription o

Re: [Tutor] unicode: alpha, whitespaces and digits

2013-12-29 Thread Mark Lawrence
On 29/12/2013 13:36, Ulrich Goebel wrote: Hallo, I have a unicode string s, for example u"abc", u"äöü", u"123" or something else, and I have to find out wether 1. s is not empty and contains only digits (as in u"123", but not in u"3.1415") or 2. s is empty or contains only whitespaces For al

[Tutor] unicode: alpha, whitespaces and digits

2013-12-29 Thread Ulrich Goebel
Hallo, I have a unicode string s, for example u"abc", u"äöü", u"123" or something else, and I have to find out wether 1. s is not empty and contains only digits (as in u"123", but not in u"3.1415") or 2. s is empty or contains only whitespaces For all other cases I would assume a "normal"