Here's my one liner (fine, fine – maybe it's two lines) :)
import re
lat = '''51°36'9.18"N'''
deg, minutes, seconds, direction = re.split('[°\'"]', lat)
(float(deg) + float(minutes)/60 + float(seconds)/(60*60)) * (-1 if direction in ['W', 'S'] else 1)