Python Workshop: Part 2

Slashdot it! Delicious Share on Facebook Tweet! Digg!
©Kirsty Pargeter, Fotolia.com

©Kirsty Pargeter, Fotolia.com

EverythingIs An Object

After the introduction to Python in the previous issue, this article deals with object orientation. As a practical exercise, you'll be programming a simple graphical user interface.

Before you design a GUI with Python, you need to understand a few basics about object-oriented programming. That's because object-oriented programming is what you'll need to create a graphical user.

Shirts Are Simply Objects

Because everything is an object in Python, you often need to design your own objects before you can use them in your program. Admittedly, this is a somewhat abstract concept. I'll use an example from daily life to make it easier to understand. A shirt is an object. Object-oriented code can represent this shirt as an abstract concept as shown in Listing 1. As always, you can find the source code for the examples on the Ubuntu User website [1].

Right on the first line, you specify the file encoding with # - * - coding: utf-8 - * - , which allows you to use characters from all languages in your (unicode) strings and comments. Of course, you need to save this file in the indicated encoding or the program will fail to start. How you go about this depends on the editor you use. With Gedit, you can use the menu item File | Save as and choose the encoding.

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF

Pages: 4

Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content