Oracle, Web, Script, SQLserver, Tips & Trick

December 16, 2017

How to convert xml into text file [python]

Filed under: phyton — sikathabis @ 10:51 am
Tags: , ,

import xml.etree.ElementTree as ET
tree = ET.parse(‘test.xml’)
notags = ET.tostring(tree.getroot(), encoding=’utf-8′,method=’text’)
f = open(‘test.txt’,’w’)
f.write(notags)
f.close()

reference : link1 | link2

Advertisements

April 22, 2012

Membuat directory secara increment menggunakan python 3.2

Filed under: phyton — sikathabis @ 4:52 pm
Tags:
def buatdir(dirfname):
        dasarfname=dirfname
        try:
            os.open(dirfname,0)
        except OSError as info:
            info2=[]
            info2.append(str(info))
            if ‘[Errno 13]’ in info2[0]: #(info2=='[Errno 13] Permission denied’)
                err=“True”
                k=0
                while (err==“True”):
                    try:
                        k=k+1
                        dirfname=dasarfname+str(k)
                        os.open(dirfname,0)
                    except OSError as info3:
                        info2=[]
                        info2.append(str(info3))
                        if ‘[Errno 2]’ in info2[0]: #=='[Errno 2] No such file or directory’: #bisa dibuat directorynya
                            err=“False”
                if err==“False”:
                    print(‘\nExecution / script file store in folder %s\n’ % dirfname)
                    os.mkdir(dirfname)
                    return dirfname
            elif ‘[Errno 2]’ in info2[0]: #info=='[Errno 2] No such file or directory’: #bisa dibuat directorynya
                print(‘Execution / script file store in folder %s\n’ % dirfname)
                os.mkdir(dirfname)
                return dirfname

March 30, 2012

Install Python 3.2 on Linux [Ubuntu]

Filed under: linux,phyton — sikathabis @ 6:36 am
Tags: ,

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

OR

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)

Filed under: phyton — sikathabis @ 10:01 am
Tags:

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

Filed under: oracle,phyton — sikathabis @ 10:42 pm
Tags: ,

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

August 14, 2011

I’ve no idea how can one go about writing a DSL in Python

Filed under: phyton — sikathabis @ 7:03 am
Tags: , ,

linkshttp://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.

(more…)

Ruby-style DSL’s in Python 2.5

Filed under: phyton — sikathabis @ 6:45 am
Tags: , ,
## {{{ 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

Filed under: phyton — sikathabis @ 5:14 am
Tags:

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.

(more…)

March 9, 2011

Satu Hari bermain dengan IDLE

Filed under: phyton — sikathabis @ 7:38 pm
Tags:

(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

Filed under: phyton — sikathabis @ 9:48 pm
Tags:
- 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

Blog at WordPress.com.

Pureblood

DONT WANNA BE NUMBER ONE

Learning is not a spectator sport

Connor McDonald's Oracle blog

Teknologi Pendidikan

Just another WordPress.com weblog

KATAKAMI

Jurnalisme Yang Dapat Dipercaya

Qey050489's Blog

Ayo Bangkit sobat..!!!!!

B. S. Totoraharjo

Orang Desa Yang Mencintai Desa dan Kebudayaannya

culturekitchen foodlab

New Food and Art in Yogyakarta

Wahyu Catur Wibowo

Musafir Dunia Maya

SQL.... Still Learning

My Reference on SQL Server

arihdyacaesar

"Tuhan tidak menuntut kita untuk menang. Tuhan hanya meminta kita untuk berjuang tanpa henti.” -ean-

neinframe

Street Photography is like a box of a chocolates, you're never know what you're gonna get - Thomas Leuthard -

Be a good Moeslim

Menuju Pribadi Muslim Sejati yang Bertaqwa

TuanSUFI

Manajemen Sholat, renungan spiritual, Teknologi Informasi

Pelangi di khatulistiwa....

Mari berbagi kebaikan, pengalaman dan senyum denganku

Angkasa13

Ceritanya saya, Pikirannya saya, Hatinya saya

sikathabis

sikathabis semua informasi disini

Don Charisma

because anything is possible with Charisma

fluoresensi

Keinginan itu pasti terwujud, entah 1 tahun, 2 tahun hingga puluhan tahun kemudian. Bersabarlah #cumanmasalahwaktu