The following code
class base:
var: int
doesn't seem to work with python2.7
and gives this error:
var: int
^
SyntaxError: invalid syntax
It seems I need python3.6 or later to use attribute annotations. I am wondering how I can achieve similar functionality for python2.7?
I think what you are actually trying to do is typing
hint in python, which is only available after python3.5 (https://docs.python.org/3/library/typing.html), so it's not possible in python2.7.
You probably should just use comments for this.