Yesterday I decided to explore python, a cross-platfom, object-oriented, programming language and in so doing discovered something that SciTE can't do!
Whilst I have a working knowledge of html and a distant memory of using Visual Basic, I could never claim to have anything other than rudimentary programming skills and I've decided that it's time to correct this deficiency. Usually I would head straight over to Amazon and buy a book that guides me through the process, but recent events have taught me that there are plenty of free resources online that are just as good as the commercial offerings if you're prepared to look for them. So, I thought that I'd make my adventure even more interesting by taking a less structured approach and only using free resources.
Fortunately the Python website provides links to some excellent tutorials for the programming n00b and ironically, I chose to go with Derrick Wolters' Learning Python (for the complete n00b). Using SciTE as my text editor, I raced through the first couple of tutorials and was soon saying hello to the world and manipulating simple numbers. However, when it came to user input variables, SciTE proved less than co-operative. Here's a simple example:
print "What is your name?"
name=raw_input()
print "Hello", name.
This is simple stuff, the interpreter simply displays (prints) What is your name? on the screen and waits for a user to input a text string. Once the user has input his name, the interpreter says hello. Unfortunately, SciTE can't handle user input in the python language: it hits an end of file condition without reading any data and returns an error. This is a problem that's been around for a while!
Fortunately, you can download IDLE from the Ubuntu Software Centre. IDLE handles user input variables with ease - here's the same code (with the text string Jogga added as the user input variable:
It's unlikely that SciTE will be fixed anytime soon, but IDLE fills the hole (or blanks!) very nicely!
Sources & References:
- Python Wiki Pages: Python for Non-Prgrammers
- Python Documentation: 24.6 IDLE
- Learning to Program: Python for the Complete N00b
- scite-interest: [scite] Python raw_input(doesn't work on Linux?) (27 February 2006 - accessed 04 August 2011)
- pyref (An Unofficial) Python Reference Wiki: EOFError
No comments:
Post a Comment