<jupyter_start><jupyter_text>Writing a Module<jupyter_code>%%writefile file1.py
def myfunc(x):
    return [num for num in range(x) if num%2 == 0]
list1 = myfunc(21)
%%writefile file2.py
import file1
file1.list1.append(100)
print(file1.list1)
! python file2.py<jupyter_output>[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 100]<jupyter_text>Passing command line arguments<jupyter_code>%%writefile file3.py
import sys
import file1
num = int(sys.argv[1])
print(file1.myfunc(num))
! python file3.py 11<jupyter_output>[0, 2, 4, 6, 8, 10]<jupyter_text>__name__ == "__main__"<jupyter_code>! python fileone.py
! python filetwo.py<jupyter_output>top level print inside fileone.py
fileone.py is being imported into another
Top leven in filetwo.py
filetwo.py is being run directly
{'fraction_non_alphanumeric': 0.12598425196850394, 'fraction_numerical': 0.06561679790026247, 'mean_word_length': 6.19811320754717, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '503316', 'license': 'MIT', 'n_tokens_mistral': 338, 'n_tokens_neox': 304, 'n_words': 79, 'path': 'Modules and Packages.ipynb', 'repo_name': 'Karthikaiselvan2019/PythonLearning', 'size': '762'}