def post_gist(func_name, git_token, gist_description=None, public=True): """Post input function source code to your Github gist.""" from inspect import getsource from github import Github, InputFileContent if not gist_description: gist_description = func_name.__doc__ me = Github(git_token).get_user() code = {func_name.__name__ + '.py': InputFileContent(getsource(func_name))} me.create_gist(public, code, gist_description)