I got some python course on udemy but whole course is in jupyter,my question is what is difference bewteen .py coding and .ipynb?why course is in jupyer but everyone on youtube coding in VsCode/Pycharm/Sublime without jupyer notebook integration
for example in jupyter
a = 20
a
and you will get result but in VsCode nothing happens you must Create New Jupyter Notebook integration for that.
It is the same result you will get but with different coding(.py/.ipynb) or i am missing something?
This is the difference between using interactive mode and script mode.
Jupyter is an IDE (Interactive Development Environment). One of the features is that when you enter an expression, the interpreter prints that value. A formal Python script doesn't display unless you explicitly tell it to do so with the print method. To get your value displayed, use
a = 20
print(a)
Thank you for response,so basically everything you can do in script mode you can do in interactive mode?(also big project)
Related
For a work/study project I have been transitioning from JupiterLab and NOtebook to Spyder, to take advantage of Spyder's included debugger (missing in the other 2 IDE).
While running my very first few lines of code as a tryout, i noticed the code in the console displays some parts that are different from what I wrote in the editor.
Specifically, I try to slice a test List as L_f = L[:k]
why the console executes/displays L_f = L[:k**+1**] ? where is that "+1" coming from?
Spyder console vs editor
no worries, solved with ChatGPT. Spyder default folded some code, compiler was looking different than Editor because in the latter 2 rows were actually folded.
I wanted to give VSC a try for developing some Python programs, where I only used PyCharm before. One of the most helpful features for me in Pycharm was the PyDev Console, where I can quickly try small snippets of code (think 3-10 lines), and adjust it to work the way I want it to.
I see VSC has a console, but it's much more like the regular IDLE console, where it's kind of hard to write these snippets of code (fixing something 2 lines prior for example is pretty much impossible).
I've been searching for an extension that'll give me a PyCharm-like console experience in VSC, but have been unable to find one. Is is out there? Or is there another way to get to the same result (like setting up a custom console based on the same PyDev console)?
Have you tried Jupyter Notebook and Interactive? There are provided by the Jupyter Extension which is bound with Python Extension.
Open the Command Palette (Ctrl+Shift+P), with the command of:
Jupyter: Create New Blank Notebook
Jupyter: Create Interactive Window
You can refer to the official docs for more details.
I find this mildly irritating as I am unable to see the reason.
The return statement (within a function) in VS Code (+ bash terminal) doesn't return any value, unless I explicit say print(function()), like given in the code below.
This doesn't happen in Spyder, it promptly returns the value in the console.
Why is this so? What am I missing?
The main reason is that in Spyder you use IPython console. It is an interactive shell which provides extra features. Since in your bash terminal the Python console is used instead of IPython, it does not return the value of the function when it is prompted.
In this question, the differences between IPython and Python consoles are discussed.
It is possible to use IPython in VS Code as well https://code.visualstudio.com/docs/python/jupyter-support-py
You may have to enable Python Data Science features in settings though (considered still experimental as of September 2020):
open the settings (press Ctrl+,) then search for datascience options
Personally, I find "Send Selection To Interactive Window" option very useful.
"python.dataScience.sendSelectionToInteractiveWindow": true,
Determines if selected code in a python file go to the terminal or to the Python interactive window when hitting Shift+Enter
I've been learning Python by using Jupyter Notebooks and have now moved over into writing normal Python scripts using VS Code (attempting OOP). As a simple example let's say I have a script that starts with a very slow function and then ends with a quick function. To debug the second function in a Notebook I would split these two functions into two cells. That way, I could run the first, slow one and store the variables. I could then run the second, fast function, make a change, rerun etc. In VS Code with the code in a normal script I have to run the whole thing end to end which takes a long time.
Is there any way to replicate this kind of debugging process in VS Code with normal Python scripts? Or indeed am I just going about debugging in completely the wrong way and I need to learn it properly?
Do you mean that when the first part is run once, the generated variables can continue to be used, and can be repeatedly modified to run in the second part?
Have you ever used jupyter notebooks in vscode?
I tried it and found that it can run separately.Reference:this.
If you've used Jupiter notebooks in vscode, you could try checking the debugging process again. Reference:this.
Besides, if it still doesn't work, hopefully you could provide more relevant information,for example: how do you operate debugging?
I have installed both PyCharm and Spyder (from Anaconda2).
However, when I run the exact same code (printing a very large array) from the python console, the console opened from Spyder printed out the array in less than five seconds, whereas the console opened from PyCharm took one minute to process and then printed the array.
I am wondering what is the reason for the difference in "processing time"? I like the auto-complete feature of PyCharm, but from my experience, it is slower than Spyder. Is there a solution?
(Spyder maintainer here) To avoid this problem in Spyder we only allow 500 lines to be shown in the console at a time (Note: This limit is configurable by the user)
So I'd say Pycharm's console doesn't have this functionality (although I can't tell that for sure).
Spyder has an integrated Jupyter Notebook and can show plots inline - comes with autocompletion that is just as good (if not much better) than PyCharm's terminal...
It comes with a live debugger that's much easier on the eye (side-by-side) and can execute code real damn fast!!!
Spyder gives you the option to autocomplete words in the console itself - Pycharm just uses the system command prompt/Terminal.