I’m Learning Python part 9
Classes In Python
Defining a Class
Classes in Python are defined like this:
Classes in Python are defined like this:
Since the last time I wrote an article Python many changes happened in my life, one of them is the release of Python 3.0 (Which is known also as Python3K and Python3000).
Python 3.0 is the first intentionally backwards incompatible Python release, which means that there are some changes you must notice before start coding in Python 3.0.
Don’t worry that much, the language has become more useful, and also there is 2to3 source-to-source conversion tool which converts your Python 2.x code to meet the requirements of Python 3.0 🙂
To find more about change in Python please refer to Python website.
First of all I wanna apologize for being late with this part, I’ve had busy days first during Shaam 2008 expo and second during some studies at the college and last busy time past launching Bawabaty project.
Continue reading “I’m Learning Python part 7”
Last time I told you to try to change a specified character, you must have failed if you tried:
>>> s = ‘c’
The error you’d get is:
TypeError: ‘str’ object does not support item assignment
This means that strings are immutable, so are core-types, numbers and tuples, they can’t be changed, while lists and dictionaries can be changed freely.
Continue reading “I’m Learning Python (part 5)”
Most of the time in programming you’ll use lists, stacks, arrays, queues and dictionaries, so instead of constructing them, Python gives you a bunch of built-in types to use. The built-in types implement the semantic of the type ADT (Abstract Data Type), and they are fast, ‘cuz some of them are written in C and C++.
Continue reading “I’m Learning Python part 4”
When you install Python on your platform you’ll find an executable called ‘python’, when you run it you’ll find a terminal and you’ll see something like the following:
Python 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
This is called interactive coding (or interactive mode), here you can write Python statements and the interpreter will execute them directly, let’s try:
>>> print “I Love Python”
I Love Python
>>> print 2 ** 10
Continue reading “I’m Learning Python part 3”
I’m Learning Python (part 2)
In the world there are more than 1 million Python user, that’s because it’s
open source, and because it is implemented for every platform, and it comes
included within Linux distributions and Macintosh computers and more.
See Python website for more.
Continue reading “I’m Learning Python part 2”
I’ll start posting this series of blogs on WordPress and CSC, here I’ll write what I’m gonna learn on my way to learning Python.
If you don’t know what Python is, or you’ve heard about it but you’re not sure what it is, my first blog will cover it for you.
Continue reading “I’m Learning Python part 1”
Hi all .Net developers and programmers.
If you’re a .Net developer or a programmer you must have heard of the Drawing namespace in System namespace, and you maybe used it to draw in your applications.
For those who used them they must have found that moving a single shape in a scene using simple code is not that easy, you’ll have to redraw the whole scene with the shape in its new location, the same thing happens for rotating and scaling a shape, so I had an idea, “Why can’t we just write Rectangle.Move(X,Y) and it moves? Why should I remember every shape coordinates to redraw a small shape in a new position?” so I answered the question.
I developed a small class that lets you manipulate your drawings as Objects, I mean that you can define a rectangle and just write Rectangle.Move(x,y) and it’ll move to the given position without much hard-coding, I defined (Rectangle, Ellipse, Lines), but you can also define your own shape, you just have to inherit the base class (MagicGraphics.Shape) and you’ll have to write your own Render sub (void) and ToString function, and you can add as much as you want of properties.
All the shapes you draw must be placed in a ShapeContainer that handles the drawing according to the Z-Order between shapes.
The following links are for the class and the testing project in VB .Net 2005:
The testing project shows how to draw, rotate and move shapes, you can start using my class directly after downloading it.
P.S.: The whole project is still Beta but I wanted to share the first build with you.
Have fun, and please tell me what do you think.