Exploring the Python Language and the Interpreter

Share

 Python is a dynamic but strictly typed programming language. It is both interpreted and compiled in that the original source code is compiled into byte code and then interpreted, but this happens transparently to the user; you do not have to explicitly ask Python to compile your code.

Python programs are written in text files having extension .py . The Python interpreter, called python (in lowercase) does not actually care about the extension; it is only for the user’s benefit (and in some operating systems to allow the file and interpreter to be linked).

You can also input Python code directly to the interpreter. This method makes for a highly interactive development style where ideas are prototyped or tested in the interpreter and then transferred into a code editor. The Python interpreter is a powerful learning tool when you are starting to use a new concept or code module.

If instead of running the Python interpreter interactively you want to execute a program stored in a file, then at the operating system prompt you simply append the name of the file after the python command:

Python comes with two helpful functions that assist you in exploring the language: dir(name) and help(name) . dir(name) tells you all of the names available in the object identified by name . help(name) displays information about the object called name . When you first import a new module, you will often not know what functions or classes are included. By looking at the dir() listing of the module, you can see what is available. You can then use help() on any of the features listed. Be sure to experiment with these functions; they are an invaluable source of information.

Would You Mind Sharing?

Share
About Dhiraj 52 Articles
Blogger on development, securities, and efficiency on web technologies.

Be the first to comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.