April 22, 2012
Membuat directory secara increment menggunakan python 3.2
March 30, 2012
Install Python 3.2 on Linux [Ubuntu]
links : http://pythonicway.blogspot.com/2011/02/install-python-32-on-linux-ubuntu.html
First of all, I don’t see a point to show you how to install Python on Windows. It’s dead easy download the installer from python.org and in few clicks you will have python up and running. Installing Python on Linux is bit different and requires some pre-work to be done.
So Let’s get started.
Note: Every Modern Linux had a python Installed. You can verify this by opening your Terminal and typing python. It will open the python shell for you. Do not remove the installed version.
Step 1: Pre-requisites for Ubuntu
To be able to compile Python Source, you will need few packages. Fire up the terminal and execute this command
sudo apt-get install build-essential libncursesw5-dev libreadline5-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev tk-dev
It will take some time to finish depending upon your bandwidth.
Step 2: Downloading Python Sources and extracting them on your disk
Download a tarball from the python site here is a direct link. Once, the download is completed you can extract the files by doing a right-click on the file and then clicking the extract option
Fire up the terminal and execute this command which will download the file first and extract it on the disk.
wget http://www.python.org/ftp/python/3.2/Python-3.2rc2.tgz && tar -xvf Python-3.2rc2.tgz
Step 3: Installing Python 3.2
Fire up a new Terminal and execute the following commands individually.
1. ./configure
2. make
3. sudo make altinstall
February 14, 2012
Google python class with Nick Parlante (text version)
www.youtube.com/watch?v=tKTZoB2Vjuk
www.youtube.com/watch?v=EPYupizJYQI
www.youtube.com/watch?v=haycL41dAhg
Day 1 part 1
C:\Python32>python hello.py asdasd vsdf dfdf
Hello
['hello.py', 'asdasd', 'vsdf', 'dfdf']
6
4
4
Hello hello.py!!!!
C:\Python32>python hello.py asdasd vsdf dfdf
File “hello.py”, line 5
def Hello(name) {
^
SyntaxError: invalid syntax
C:\Python32>python hello.py asdasd vsdf dfdf
File “hello.py”, line 8
}
^
SyntaxError: invalid syntax
(more…)
February 13, 2012
cx_oracle for python
cx_Oracle is a Python extension module that allows access to Oracle databases and conforms to the Python database API specification. This module is currently built against Oracle 9.2, 10.2, 11.1 and 11.2. For more information on the database API specification, see here. Use the provided setup.py to build and install the module which makes use of the DistUtils module made available in Python 2.0 and up.
If you are looking for support with Tuxedo servers, go here.
Download 5.1.1 released October 10, 2011
- Windows x86 Installer (Oracle 10g, Python 2.6)
- Windows x86 Installer (Oracle 10g, Python 2.7)
- Windows x86 Installer (Oracle 10g, Python 3.2)
- Windows x86 Installer (Oracle 11g, Python 2.6)
- Windows x86 Installer (Oracle 11g, Python 2.7)
- Windows x86 Installer(Oracle 11g, Python 3.2)
- Windows amd64 Installer (Oracle 10g, Python 2.6)
- Windows amd64 Installer (Oracle 10g, Python 2.7)
- Windows amd64 Installer (Oracle 10g, Python 3.2)
- Windows amd64 Installer (Oracle 11g, Python 2.6)
- Windows amd64 Installer (Oracle 11g, Python 2.7)
- Windows amd64 Installer(Oracle 11g, Python 3.2)
- CentOS 5 i386 RPM (Oracle 10g, Python 2.4)
- (more…)
August 14, 2011
I’ve no idea how can one go about writing a DSL in Python
links: http://news.ycombinator.com/item?id=403690
There’s multiple definitions, so what follows is not authoritative, but in my hummble opinion it will help you understand the field much better, as well as why so many people seem to be talking past each other as they silently adopt one definition while arguing with someone based on another.
A strong DSL is a specialized language designed for a specific task, with its own parser and syntax not directly based on another language. Ideally, it is not Turing complete, because that opens a huge can of worms, and much of the point of a strong DSL is to avoid this can of worms. The DSL should be carefully designed in conjunction with the eventual users, who most likely will not be programmers. I’ve heard of impressive results with this approach, but I’ve never witnessed them firsthand. This definition is favored by Martin Fowler, and much less importantly/impressively, me.
Ruby-style DSL’s in Python 2.5
## {{{ http://code.activestate.com/recipes/534150/ (r1)
from __future__ import with_statement
from contextlib import contextmanager
class Table(object):
def __init__(self, table_name):
self.table_name = table_name
self.fields = {}
def __setattr__(self, attr, value):
if attr in ("fields", "table_name"):
object.__setattr__(self, attr, value)
else:
self.fields[attr] = value
def execute(self):
print "Creating table %s with fields: %s" % (self.table_name, self.fields)
@contextmanager
def create_table(table_name):
table=Table(table_name)
yield table
table.execute()
#try it!
with create_table("Employee") as t:
t.first_name = {"type" : "char", "length" : 30 }
t.last_name = {"type" : "char", "length" : 30 }
t.age = {"type" : "int"}
#prints:
#Creating table Employee with fields: {'first_name': {'length':
#30, 'type': 'char'}, 'last_name': {'length': 30, 'type': 'char'}, 'age':
#{'type': 'int'}}
## end of http://code.activestate.com/recipes/534150/ }}}
July 16, 2011
Writing a domain specific language DSL with python
http://fmeyer.org/en/writing-a-DSL-with-python.html
Writing a domain specific language DSL with python
A domain-specific language is a piece of software designed to be useful for a specific task in a fixed problem domain, they’re gaining popularity because they enhance productivity and reusability of artifacts. DSLs also enable expression and validation of concepts at the level of abstraction of the problem domain, this approach is very useful when you need to describe a user interface, a business process, a database, or the flow of information.
March 9, 2011
Satu Hari bermain dengan IDLE
(Indonesian translation by I Wayan Wandira)
Halaman ini dimaksudkan untuk membantu pendatang baru di Python yang merasa sedikit bingung. Satu pertanyaan yang sering muncul adalah : Ok, saya sudah menginstall Python….ummm… sekarang bagaimana ?
Mungkin akan lebih bagus sebuah arahan secara “visual” digunakan untuk mengurangi kegelisahan yang timbul. Itulah sebabnya kenapa halaman ini dibuat. Adapun langkahnya adalah dengan melakukan sebuah sesi kecil dengan IDLE : Lingkungan Pemrograman Python yang Terintegrasi. IDLE didesain untuk menyediakan cara singkat mempelajari bahasa ini. Pada sesi ini, saya akan membuat beberapa kesalahan, hanya untuk menunjukkan bahwa apakah sebenarnya yang terjadi ketika sesuatu tidak berjalan sebagaimana mestinya.
Berhubung ini adalah dokumen online. Jika anda punya beberapa saran, atau jika anda ingin mengkoreksi atau memperbaiki silahkan kirim email ke dyoo@hkn.eecs.berkeley.edu.Tambahan : jangan lupa bahwa ada sumber referensi di mailing list Python tutor. Kami adalah sekelompok orang yang saling berbagi hal hal menarik tentang Python. Kita akan belajar bersama , jadi silahkan subscribe dan bergabung bersama kami.
(more…)
November 24, 2010
Phyton
- Format Angka
'{:1,.2f}'.format(123.0) menjadi '123.00'
'{:7,.1f}'.format(123.0) menjadi ' 123.0'
'{:8,d}'.format(123.0) menjadi '1,200.00'
import sys
try: f = open('myfile.txt') s = f.readline() i = int(s.strip()) except IOError as (errno, strerror): print "I/O error({0}): {1}".format(errno, strerror) except ValueError: print "Could not convert data to an integer." except: print "Unexpected error:", sys.exc_info()[0] raise