This month I have an active subscription to cbtNuggets (http://www.cbtnuggets.com), a training site for IT stuff. Once I finished my mission, I found that I have some time left in which I can learn something else. Since there isn’t a course for git, I chose the next best thing: a course in Python taught by Ben Finkel.
So far the material is basic and can be learned from many web sources, so I’m not repeating it here. There are a couple chewy nuggets that I’d like to remember though – which is what this blog is about!
- The online python documentation can be found at https://docs.python.org.
- There is a library of python code and stuff located at https://pypi.python.org/pypi
- Python 2.x is preinstalled on OS X (I love Apple!). To find the version running on your Mac, use the command python –version or python -V at a command line. Mine is running 2.7.6.
- Launch python’s interactive mode from the terminal using the command python.
- Execute a python program file from the terminal using the command python <filename>.
That’s all for tonight. I’m off to beg my lovely financial officer for a copy of the UltraEdit Studio!
Today at lunch I chose to find out what people mean when they reference an IDE. In my mind an IDE is a hard drive interface – their uses certainly don’t work with my definition. According to Wikipedia an IDE is an Integrated Development Environment, which makes a lot more sense in their context. In the spirit of learning Python I went looking for IDEs which target Python and found an interesting one that needs more attention: PyCharm. It can be found here:
http://www.jetbrains.com/pycharm/?fromMenu
Today’s nugget was about installing PyQt to OS X. PyQt is a graphical package that the instructor likes. An alternative is Tkinter, based on the Tk language. But in order to follow the other nuggets and use the sample code, I’ve installed PyQt. There are 4 major steps in the installation:
1. Download and install xCode from the app store. Accept the license from a terminal with the following command: sudo xcodebuild -license
2. Download sip from Riverbank Computing at this link: http://www.riverbankcomputing.co.uk/software/pyqt/intro
2a. Install sip with the following 3 statements:
python configure.py -d /Library/Python/2.7/site-packages –arch x86_64
make
sudo make install
3. Download the Qt library at this link:
https://www.qt.io
3a. Install the Qt library from the dmg file using the included installer.
4. Download PyQt from Riverbank Computing at this link:
http://www.riverbankcomputing.co.uk/software/pyqt/intro
4a. Install the PyQt with the following 3 statements:
python configure.py -q /usr/bin/qmake-4.8 -d /Library/Python/2.7/site-packages –use-arch x86_64
make
sudo make install
At this point PyQt should work.
I’ve been continuing to view additional nuggets as I get the chance – hopefully this weekend I can finish them all. Today’s nugget had to do with error handling. The important chunk is where to find a list of Exceptions which can be trapped easily within the code. Here is the link:
https://docs.python.org/2/library/exceptions.html
Happy coding!