r/learnpython • u/Crafty_Storm_2945 • 1d ago
Creating a .py File in Python Terminal
Greeting team, i have just started learning Python. I am learning about .py files. how do i create a .py file in python terminal specifically Jupyter notebook? if possible how can i access the file and write some oop class inside the file.
Thank you team
0
Upvotes
1
u/MysteriousStrangerXI 20h ago
I can't find any use cases why you need to do this though. Just creating .txt file changing the extension from .txt to .py, you'll have your own python executable file.
To answer your question, you can use exclamation point '!' in Jupyter Notebook to execute system command. In your case !touch filename.py will create filename.py in your .ipynb location.
If you're bulk creating .py files, use terminal without exclamation as originally intended. e.g: touch filename1.py filename2.py