Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

What is the importance of Python's Shell?

In Kenneth's intro video to the shell, I didn't really get from the content why the shell is important, especially using it on a daily basis. From what I understand, Python's shell is like a temporary sandbox. You can execute your code in it, but that's it right? I'm not understanding how that's applicable to everyday use when there are better tools that, for example, might show you where errors are vs. just not running in Python's shell...so can someone elaborate for me on why the shell is useful & why Kenneth would use this on a daily basis?

hey nekilof,

python shell is an amazing tool. Anytime you want to try some new code, you can do it in the shell, without having to go through the process of making a .py file compile it etc.

For example, let's say you just want to test if you have a certain package installed, like BeautifulSoup for example. Instead of making a .py file, you'd go straight into python shell and type:

from bs4 import BeautifulSoup

And see if you get an error. But that's just one example. You can check how python data structures work on the shell, without having to actually write an entire file. This youtube video about web scrapping with python shows you clearly how powerful the shell is:

https://www.youtube.com/watch?v=XQgXKtPSzUI&t=1528s

1 Answer

Realistically it wouldnt be practical to use it for everyday use. It can be clunky to use and as you said its essentially a sandbox so everything that you do in it will be gone as soon as you close it. Kenneth and a lot of people use it for teaching beginner Python courses as its a quick and easy way to show how variables and methods work and prove some of the topics they are talking about in an easy way to see.

But other than that when working on actual Python you would just use a text editor or a fully fledged IDE like PyCharm