Skip to content

Adding-function-call-to-cell #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions p2j/p2j.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ def python2jupyter(source_filename: str, target_filename: str, overwrite: bool =
# (next line is nothing AND next line is part of a function)
if (is_end_of_code or next_is_nothing) and not (next_is_nothing and next_is_function):
arr.append("{}".format(buffer))

# Append the function call at the end of the each function
# This avoids efforts of writing statement of calling the function for every cell
fcall = arr[0].strip().lstrip("def ")
idx = fcall.find('(')
fcall = fcall[:idx]+'()'
arr.append("")
arr.append(fcall)

CODE["source"] = arr
cells.append(dict(CODE))
arr = []
Expand Down