Wednesday, October 6, 2010
Python tutorial to develop and deploy Python project with Google App Engine
Getting Started: Python - This tutorial describes how to develop and deploy a simple Python project with Google App Engine. The example project, a guest book, demonstrates how to use the Python runtime environment, and how to use several App Engine services, including the datastore and the Google user service.
Monday, May 10, 2010
About Pygame
Pygame is a set of Python modules designed for writing games. Pygame adds functionality on top of the excellent SDL library. This allows you to create fully featured games and multimedia programs in the python language. Pygame is highly portable and runs on nearly every platform and operating system. Pygame itself has been downloaded millions of times, and has had millions of visits to its website.
Pygame is free. Released under the LGPL licence, you can create open source, free, freeware, shareware, and commercial games with it. See the licence for full details.
For a nice introduction to pygame, examine the line-by-line chimp tutorial, and the introduction for python programmers.
Thursday, April 8, 2010
PyPy 1.2 Released
PyPy is a reimplementation of Python in Python, using advanced techniques to try to attain better performance than CPython. Many years of hard work have finally paid off. Our speed results often beat CPython, ranging from being slightly slower, to speedups of up to 2x on real application code, to speedups of up to 10x on small benchmarks. This post describes what we did on PyPy during the last year, leading up to those results.
...
source: PyPy 1.2 Released - Google Open Source Blog
...
source: PyPy 1.2 Released - Google Open Source Blog
Monday, February 8, 2010
Arithmetic operation involving only integers do not always return an integer
int/int
Unlike C, in Python arithmetic operation involving only integers do not always return an integer. If you want a truncated integer returned from a integer division, use // instead of /.
Lets see the examples:
Unlike C, in Python arithmetic operation involving only integers do not always return an integer. If you want a truncated integer returned from a integer division, use // instead of /.
Lets see the examples:
a = 3;
b = 1;
x = a/b;
print(type(a), " / ", type(b), " produce ", type(x));
a = 3.0;
b = 1.0;
x = a/b;
print(type(a), " / ", type(b), " produce ", type(x));
a = 3;
b = 1;
x = a//b;
print(type(a), " // ", type(b), " produce ", type(x));
a = 3.0;
b = 1.0;
x = a//b;
print(type(a), " // ", type(b), " produce ", type(x));
Indentation and block
Indentation and block
Unlike most other programming language such as c, java, in which using braces to define block; Python use whitespace and indentation to define block structure.
Example 1:
Example 2:
IDLE, the default IDE of Python, automatically indents lines for you.
Unlike most other programming language such as c, java, in which using braces to define block; Python use whitespace and indentation to define block structure.
Example 1:
x = 0;
while(x < 10):
x += 1;
y = x;
print("x = ", x);
print("y = ", y);
Example 2:
x = 0;
while(x < 10):
x += 1;
y = x;
print("x = ", x);
print("y = ", y);
IDLE, the default IDE of Python, automatically indents lines for you.
Friday, January 8, 2010
Python is dynamically typed
Python is dynamically typed, the type of a object, or variable, is determined ar runtime. If you assign a int to g, g is int; then you re-assign a float to g, g is a float.
The Python build-in funtion type can be used to check the type of a object.
Try the following code:
The Python build-in funtion type can be used to check the type of a object.
Try the following code:
g = 1 print(g, " g is ", type(g)) g = 5/2 print(g, " g is ", type(g)) g = 5//2 print(g, " g is ", type(g)) g = False print(g, " g is ", type(g)) g = True * 1 print(g, " g is ", type(g)) g = "Hello" print(g, " g is ", type(g)) g = ['hello', 'how', 'are', 'you'] print(g, " g is ", type(g)) g = [1, 2, 3, 'you'] print(g, " g is ", type(g)) print(g[0], " g[0] is ", type(g[0])) print(g[3], " g[3] is ", type(g[3])) g = 3 + 2j print(g, " g is ", type(g))
How to create a .py script in IDLE?
To create a .py script using IDLE
Start IDLE in Ubuntu, click Application -> Programming -> IDLE (using Python-3.1)
Click File -> New Window
A new window will be open, you can type your Python script here.
Then, you can save (File->Save or File->Save As) it as .py script file, or run it in Python Shell (Run->Run Moduel).
Start IDLE in Ubuntu, click Application -> Programming -> IDLE (using Python-3.1)
Click File -> New Window
A new window will be open, you can type your Python script here.
Then, you can save (File->Save or File->Save As) it as .py script file, or run it in Python Shell (Run->Run Moduel).
Thursday, January 7, 2010
Hello Python
To start your very first code, hello python:
Start IDLE:
Click Applications from Ubuntu top menu, then click Programming and IDLE (using python-3.1)
type the command below to say hello to Python, and RETUEN.
Start IDLE:
Click Applications from Ubuntu top menu, then click Programming and IDLE (using python-3.1)
type the command below to say hello to Python, and RETUEN.
print ("hello")
Tuesday, January 5, 2010
Install Python 3.1 (the current version) on Ubuntu 9.10.
To install Python 3.1 (the current version) on Ubuntu 9.10.
Select Application -> Ubuntu Software Center from Ubuntu top menu.
Type Python3.1 inside the search box.
Select Python(3.1) and click the arrow on the right, and click Install to continuous. (You will be asked for password to continuoues)
Ubuntu Software Center will be downloaded and Installed automatically.
Then, you can go back to Ubuntu Software Center to install IDLE (using Python-3.1), a Integrated Development Environment for Python (v3.1), also if you want. It's suggested to do so.
After installed, you can close Ubuntu Software Center.
If you have a old version of Python installed on your Ubuntu, may be 2.6, both version of Python will be kept in your machine. So go to check the installed Python(s) now.
Start a Terminal, type 'python' will start your original python. To start the new installed Python 3.1, type 'python3.1'.
The IDLE will be installed under Application -> Programming -> IDLE (using Python-3.1).
Select Application -> Ubuntu Software Center from Ubuntu top menu.
Type Python3.1 inside the search box.
Select Python(3.1) and click the arrow on the right, and click Install to continuous. (You will be asked for password to continuoues)
Ubuntu Software Center will be downloaded and Installed automatically.
Then, you can go back to Ubuntu Software Center to install IDLE (using Python-3.1), a Integrated Development Environment for Python (v3.1), also if you want. It's suggested to do so.
After installed, you can close Ubuntu Software Center.
If you have a old version of Python installed on your Ubuntu, may be 2.6, both version of Python will be kept in your machine. So go to check the installed Python(s) now.
Start a Terminal, type 'python' will start your original python. To start the new installed Python 3.1, type 'python3.1'.
The IDLE will be installed under Application -> Programming -> IDLE (using Python-3.1).
Monday, January 4, 2010
Subscribe to:
Posts (Atom)