On Mon, 26 Feb 2018, Roger Lea Scherer wrote:
""" ensure input is no other characters than digits
sudocode: if the input has anything other than digits
return digits """
p = re.compile(r'[^\D]')
I'm not so great at regular expressions, but this regex appears to be
searching for a str
On Mon, 26 Feb 2018, Terry Carroll wrote:
Instead of looking fo re xcaprions..
Wow. That should read "Instead of looking for exceptions..." Something
really got away from me there.
--
Terry Carroll
carr...@tjc.com
___
Tutor maillist - Tutor@pyth
On Mon, Feb 26, 2018 at 11:01:49AM -0800, Roger Lea Scherer wrote:
> The first step is to input data and then I want to check to make sure
> there are only digits and no other type of characters. I thought regex
> would be great for this.
I'm going to quote Jamie Zawinski:
Some people, when
On 27/02/18 05:13, Cameron Simpson wrote:
> hard to debug when you do. That's not to say you shouldn't use them, but many
> people use them for far too much.
> Finally, you could also consider not using a regexp for this particular task.
>
> Python's "int" class can be called with a string,
Alan Gauld via Tutor wrote:
> On 27/02/18 05:13, Cameron Simpson wrote:
>
>> hard to debug when you do. That's not to say you shouldn't use them, but
>> many people use them for far too much.
>
>
>> Finally, you could also consider not using a regexp for this particular
>> task. Python's "int"
On 27/02/18 09:50, Peter Otten wrote:
>> def all_digits(s):
>> return all(c.isdigit() for c in s)
>
> Note that isdigit() already checks all characters in the string:
Ah! I should have known that but forgot.
I think the singular name confused me.
> The only difference to your suggestion is