I think there is no way make a python-like syntax parser with ONLY lex/yacc, because lex/yacc can deal with Context Free Grammar only, but a python-like syntax is context sensitive.
The reason is, if you want to find whether a statement and the previous one is in the same block, you should let this statement knows the indentation of the previous one, that's the context.
I suggest you make some additional logic besides lex/yacc to accomplish that, and that won't be so hard. You could read codes here, in "parser" and "grammar" modules (sorry there is no doc and readme's Chinese).
The key is, let lex/yacc part parse single statement, with indentation level, and write something packing statements into blocks.