[Tutor] class and methods/functions

Jacob S. keridee at jayco.net
Sat Oct 22 18:48:19 CEST 2005


>>   def nameCheck(self, value):
>> >         import re
>> >         tempREG = re.match('.*:.*',value)
>> >         return str(tempREG) != 'None'
>>
>> Still a syntax error here!
>>
> Code is working as I thought it would. What syntax error do I have?

This could be written better.

def nameCheck(self, value):
    tempREG = re.match('.*:.*',value)
    return tempREG != None

There's no need to convert to string. None is a type that you can check 
against directly.

Jacob 



More information about the Tutor mailing list