#NEWLINE# def isIPAddress( addr ) : #NEWLINE# #INDENT# '\n    Determine whether the given string represents an IPv4 address.\n\n    @type addr: C{str}\n    @param addr: A string which may or may not be the decimal dotted\n    representation of an IPv4 address.\n\n    @rtype: C{bool}\n    @return: C{True} if C{addr} represents an IPv4 address, C{False}\n    otherwise.\n    ' #NEWLINE# dottedParts = addr . split ( '.' ) #NEWLINE# if ( len ( dottedParts ) == 4 ) : #NEWLINE# #INDENT# for octet in dottedParts : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# value = int ( octet ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( value < 0 ) or ( dottedParts > 255 ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return True #NEWLINE# #UNINDENT# return False