- is a friendly and readable high-level programming language
- is an interpreted programming language (though there's compilation behind the scenes)
- what's the difference between the two? →
- why might it matter? →
- supports multiple programming paradigms
- well-known as a mainstream programming language
- comes with batteries included
- QUESTION - what's the difference between compiled and interpreted again?
- INFO - technically it's compiled to bytecode, much like Java or c#, but there's no explicit compilation step
- QUESTION - what paradigm are we using again?
- INFO - imperative / procedural, object oriented functional
- INFO - comes with a lot of functionality "out-of-the-box"
Where You've Seen It Before
- web frameworks like:
- EVE online
- original Bittorent client
- embedded scripting in Maya and Blender
QUESTION - does anyone use any of these sites?
Some Python History
- yes, it was named after Monty Python
- based on ABC
- invented in 1991 by this bearded Dutch guy (Guido van Rossum):
- ABC - teaching / prototyping language meant to replace BASIC, Pascal, etc
- Also known as Python's "Benevolent Dictator for Life"
Where It's Going
- two active branches of Python: 2.x and 3.x
- Python Enhancement Proposals (PEPs).
- Python Software Foundation (PSF)
- ABC - teaching / prototyping language meant to replace BASIC, Pascal, etc
- 3.x meant to remove duplicate features and perceived flaws with prior implementation
- 3.x is not backward compatible, but some features have been backported
- PEPs provide structure for evolution and dev of Python; add language features as well as conventions
- PyPy - Python in Python!, Jython - for the JVM, etc.
- PSF - non-profit organization that provides organizational structure, governance and community building
So, Which Version of Python, Exactly?
All of the in-class examples, exercises and homework solutions will target 3.x. We're using Python 3 because it:
- is an excellent language for learning programming (readable, consistent, etc.)
- smooths over many of the perceived flaws and inconsistencies in Python 2
- is the future of Python
Note, however, that Python 3 is not yet widely deployed in production systems.
But, How Will We Write Python Programs?
Python Programs Are Just Text
A text file is simply a file that contains human readable text.
- some text files have .txt as its extension
- you might have opened a text file in Notepad or TextEdit
- Python programs are text files that (usually) end in .py (for example, hello.py)
Why can't We Use a Word Processor Like MicroSoft Word or Pages?
- a .doc or .rtf file isn't actually just text
- it has a bunch of other stuff in it that Pages or Word uses to render or display your file
- consequently, you can't use a word processor to create plain text files
You'll Need a Text Editor or an IDE
- a text editor is specifically used for editing text files
- Some text editors, such as Notepad or TextEdit are very simple
- Others contain features that aid in programming
- an IDE is an application that is meant for reading and writing programs
- It stands for Integrated Development Environment
- Aside from editing text, it has many features that help programmers
an IDE is pretty much a text editor plus some other stuff
What's Makes a Good IDE?
- a full featured text editor with:
- syntax highlighting - to make your program more readable
- syntax checking - to make sure your program's syntax is correct
- inline documentation / help
- code auto-completion
- text editing tools - such as the ability to insert predefined chunks of code
- an integrated interactive shell - to easily experiment with your programming language
- an integrated debugger - to step through your program
We'll be Using IDLE
- IDLE is an IDE (written in Python!)
- it's simple enough to not get in the way, but it has some very helpful features
- it's usually bundled with Python, so it should be present when you install Python
- as an IDE, it has two main functions:
- text editor →
- interactive Python shell →
- DEMO text editor
- DEMO - interactive shell
- Show:
- syntax highlighting
- syntax checking
- auto-complete and integrated help
Text Editor vs Interactive Python Shell
Again, IDLE comes with both:
- a text editor
- an interactive Python shell
Both allow you to write code! So, what's the difference? →
Text Editor
The usual workflow is: →
- start writing a program or load an existing one
- make changes to your program
- save your changes
- run your saved program
It's similar to working on a regular document.
Interactive Python Shell
- code is entered line-by-line
- code is executed as each line is entered!
- you get immediate feedback
- generally, you won't be able to save and re-run all of the code that you've entered
- …and any output from programs that you've edited and run through the text editor will be placed here