def follow(self, something, follow=True):
from .question import Question<EOL>from .topic import Topic<EOL>from .collection import Collection<EOL>if isinstance(something, Author):<EOL><INDENT>if something.url == self.url:<EOL><INDENT>return False<EOL><DEDENT>data = {<EOL>'<STR_LIT>': something.xsrf,<EOL>'<STR_LIT>': '<STR_LIT>' if follow else '<STR_LIT>',<EOL>'<STR_LIT>': json.dumps({'<STR_LIT>': something.hash_id})<EOL>}<EOL>res = self._session.post(Follow_Author_Url, data=data)<EOL>return res.json()['<STR_LIT:r>'] == <NUM_LIT:0><EOL><DEDENT>elif isinstance(something, Question):<EOL><INDENT>data = {<EOL>'<STR_LIT>': something.xsrf,<EOL>'<STR_LIT>': '<STR_LIT>' if follow else '<STR_LIT>',<EOL>'<STR_LIT>': json.dumps({'<STR_LIT>': str(something.qid)})<EOL>}<EOL>res = self._session.post(Follow_Question_Url, data=data)<EOL>return res.json()['<STR_LIT:r>'] == <NUM_LIT:0><EOL><DEDENT>elif isinstance(something, Topic):<EOL><INDENT>data = {<EOL>'<STR_LIT>': something.xsrf,<EOL>'<STR_LIT>': '<STR_LIT>' if follow else '<STR_LIT>',<EOL>'<STR_LIT>': json.dumps({'<STR_LIT>': something.tid})<EOL>}<EOL>res = self._session.post(Follow_Topic_Url, data=data)<EOL>return res.json()['<STR_LIT:r>'] == <NUM_LIT:0><EOL><DEDENT>elif isinstance(something, Collection):<EOL><INDENT>data = {<EOL>'<STR_LIT>': something.xsrf,<EOL>'<STR_LIT>': something.cid<EOL>}<EOL>res = self._session.post(<EOL>Follow_Collection_Url if follow else Unfollow_Collection_Url,<EOL>data=data)<EOL>return res.json()['<STR_LIT:r>'] == <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>
关注用户、问题、话题或收藏夹

        :param Author/Question/Topic something: 需要关注的对象
        :param bool follow: True-->关注，False-->取消关注
        :return: 成功返回True，失败返回False
        :rtype: bool