def getxy(s):
return s[s.rfind('.')+1:s.rfind('_')]


a=getxy('.foo.xxx_var')