Hi All Thankyou verymuch for ur inputs.
Hope u might have come across the string deprecation thought of in Python 3.0 as a result of which we need to use all of these as some objects For example : string.lower(str) needs to be some thing like str.lower(). Can u tell me whether such a change in the common python would require these string.digits to be changed. If so wat would be ur suggestions Thanks and regards Anoop John McMonagle wrote: > On Mon, 2006-07-24 at 22:19 -0700, Anoop wrote: > > Hi All > > > > I am getting two different outputs when i do an operation using > > string.digits and test.isdigit(). Is there any difference between the > > two. I have given the sample program and the output > > > > Thanks for ur inputs > > > > Anoop > > > > #1: > > ~~ > > import string > > > > test='121206' > > > > if test not in string.digits: > > print "I am Not Digit" > > else: > > print "I am Digit" > > > > #2: > > ~~ > > import string > > > > test='121206' > > > > if not test.isdigit(): > > print "I am Not Digit" > > else: > > print "I am Digit" > > > > Output > > ~~~~~ > > #1:I am Not Digit > > #2:I am Digit > > > > Thnks and Rgds > > > > Anoop > > > > > string.digits is the string constant '0123456789' > > So your test, "if test not in string.digits:" will evaluate True because > '121206' is not in '0123456789'. > > Whereas test.isdigit() returns true if all the characters in test are > digits. > > So yes, there is a big difference between the two. > > Regards, > > John > > > > -- > This message has been scanned for viruses and > dangerous content by MailScanner, and is > believed to be clean. -- http://mail.python.org/mailman/listinfo/python-list