String contains only digits
Hi! I have a form variable (select/option) which gives a number, or value "A". I have to check the value, is it contains only digits. I use in python script "if container.REQUEST.state in '0123456789'". Is there any other way to check? Because string object has neither "isdecimal", "isdigit" nor "isnumeric" method. I use zope 2.3.3 under Linux. Thanks: Lajos Kerekes
Does it have to be a string? Can you check for int instead? Russell On Wednesday 29 August 2001 07:21, you wrote:
Hi!
I have a form variable (select/option) which gives a number, or value "A". I have to check the value, is it contains only digits. I use in python script "if container.REQUEST.state in '0123456789'". Is there any other way to check? Because string object has neither "isdecimal", "isdigit" nor "isnumeric" method. I use zope 2.3.3 under Linux.
Thanks:
Lajos Kerekes
_______________________________________________ Zope maillist - http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
This has never turned me down. Perhaps not rocket surgery but useful. try: is_int = int(intordigit) except: is_int = 0 peter ----- Original Message ----- From: "Kerekes Lajos" <lkerekes@xperts.hu> To: <zope@zope.org> Sent: Wednesday, August 29, 2001 1:21 PM Subject: [Zope] String contains only digits
Hi!
I have a form variable (select/option) which gives a number, or value "A". I have to check the value, is it contains only digits. I use in python script "if container.REQUEST.state in '0123456789'". Is there any other way to check? Because string object has neither "isdecimal", "isdigit" nor "isnumeric" method. I use zope 2.3.3 under Linux.
Thanks:
Lajos Kerekes
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Kerekes Lajos -
Peter Bengtsson -
Russell Hires