Reputation: 637
I have read about .py
and .ipy
, also the difference between python, ipython and notebook.
But the question is: what is the real difference between .py
and .ipynb
file?
Is .ipynb
file just more convenient to be run on jupyter notebook, or anything more? I am wondering because I am thinking about which format to be used for publishing on GitHub.
Thanks
Upvotes: 48
Views: 120785
Reputation: 1644
.py
is a regular python file. It's plain text and contains just your code.
.ipynb
is a python notebook and it contains the notebook code, the execution results and other internal settings in a specific format. You can just run .ipynb
on the jupyter environment.
Better way to understand the difference: open each file using a regular text editor like notepad (on Windows) or gedit (on Linux).
Save on git the .ipynb
if you want to show the results of your script for didatic purposes, for example. But if you are going to run your code on a server, just save the .py
Upvotes: 53
Reputation: 11600
Adding @Josir answer, the below information is very useful for open .ipynb
file using PyCharm.
pip install jupyterlab
).jupyter-lab
command..ipynp
file.
Here is documentation https://jupyterlab.readthedocs.io/en/latest/
Upvotes: 10
Reputation: 6854
py
means PYthon
ipynb
means Interactive PYthon NoteBook - which is now known as Jupyter notebook.
The latter one is merely a Python script with descriptive contents - you describe what your data is doing by means of Python script and some funny texts. That's pretty much it - and also, you need a specific editor e.g. PyCharm or Google Collab to open and run it.
Upvotes: 20
Reputation: 120
I think the answer here might help you: https://stackoverflow.com/a/32029027/11924650
.ipy indicates that it's an IPython script. The only difference between IPython scripts and normal Python scripts is that IPython scripts can use IPython magics, e.g. %timeit, and run system commands as !echo Hi.
Upvotes: -2