<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-159364773623307002</id><updated>2024-09-04T07:28:46.781-07:00</updated><category term="Java"/><category term="Python"/><category term="C#"/><category term="VB.Net"/><category term="Tip and Triks"/><category term="example"/><title type='text'>Ini adalah suatu pilihan</title><subtitle type='html'>keinginan mencapai sesuatu yang diharapkan</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>30</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-2626804737793090532</id><published>2016-05-09T03:15:00.001-07:00</published><updated>2016-05-09T23:23:14.009-07:00</updated><title type='text'>Basic CRUD Operations Using cx_Oracle, Part 4: Update</title><content type='html'>&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2oIO4XNet0G4pFnBTktXaHY6G4X6ulnKTUbZB63Z0xRPiyx1VRmNhGY5TmvZyAYyUUpjkHzqucNJMhyphenhyphenhlkIIFKV9oqgXFBk_AehikFvji7Vq1_gRusWBFsfV1KKjXi1tQuXi_ylgyx3c/s1600/python.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2oIO4XNet0G4pFnBTktXaHY6G4X6ulnKTUbZB63Z0xRPiyx1VRmNhGY5TmvZyAYyUUpjkHzqucNJMhyphenhyphenhlkIIFKV9oqgXFBk_AehikFvji7Vq1_gRusWBFsfV1KKjXi1tQuXi_ylgyx3c/s1600/python.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;In this post, we’re going to take a look at the &lt;b&gt;U&lt;/b&gt; in &lt;b&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Create,_read,_update_and_delete&quot;&gt;CRUD&lt;/a&gt;&lt;/b&gt;: Update. &amp;nbsp;We use the &lt;i&gt;cx_Oracle&lt;/i&gt; driver to &lt;i&gt;update&lt;/i&gt; some data in the database tables, using the connection object created in the &lt;a href=&quot;http://learncodeshare.net/2015/06/02/basic-crud-operations-using-cx_oracle/&quot;&gt;Initial Setup&lt;/a&gt; section of the first post in this series.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;WARNING: PLEASE REVIEW ALL EXAMPLE CODE AND ONLY RUN IT IF YOU ARE SURE IT WILL NOT CAUSE ANY PROBLEMS WITH YOUR SYSTEM.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;We will be using a helper function get_all_rows(). &amp;nbsp;This function encapsulates a select statement used to verify that the updates worked. The select functionality is covered in the R part of this series, so we won’t go into the details here.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;i&gt;Sample&lt;/i&gt; :&lt;/span&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre class=&quot;displaycode&quot; style=&quot;background: rgb(247, 247, 247) !important; border: 1px solid rgb(204, 204, 204); clear: right; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, Liberation, fixed, monospace; font-size: 11px; margin-bottom: 6px !important; outline: 0px; overflow: auto; padding: 5px 10px 5px 3px !important; text-align: start; vertical-align: baseline; width: 780px;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;def get_all_rows(label, data_type=&#39;people&#39;):
  # Query all rows
  cur = con.cursor()
  if (data_type == &#39;pets&#39;):
    statement = &#39;select id, name, owner, type from cx_pets order by owner, id&#39;
  else:
    statement = &#39;select id, name, age, notes from cx_people order by id&#39;
  cur.execute(statement)
  res = cur.fetchall()
  print(label + &#39;: &#39;)
  print (res)
  print(&#39; &#39;)
  cur.close()&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;span class=&quot;fullpost&quot;&gt;

&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Add this function to the top of your file.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;Resetting the Data&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;To keep the examples clean and precise, we will reset the data at times.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span class=&quot;fullpost&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Create a new file called reset_data.py with the following code and then run it whenever you would like to reset the data. (Notice this version adds pet data not included in other sections.)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span class=&quot;fullpost&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre class=&quot;displaycode&quot; style=&quot;background: rgb(247, 247, 247) !important; border: 1px solid rgb(204, 204, 204); clear: right; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, Liberation, fixed, monospace; font-size: 11px; margin-bottom: 6px !important; outline: 0px; overflow: auto; padding: 5px 10px 5px 3px !important; text-align: start; vertical-align: baseline; width: 780px;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;import cx_Oracle
import os
connectString = os.getenv(&#39;db_connect&#39;)
con = cx_Oracle.connect(connectString)
cur = con.cursor()
# Delete rows
statement = &#39;delete from cx_pets&#39;
cur.execute(statement)
# Reset Identity Coulmn
statement = &#39;alter table cx_pets modify id generated BY DEFAULT as identity (START WITH 8)&#39;
cur.execute(statement)
# Delete rows
statement = &#39;delete from cx_people&#39;
cur.execute(statement)
# Reset Identity Coulmn
statement = &#39;alter table cx_people modify id generated BY DEFAULT as identity (START WITH 3)&#39;
cur.execute(statement)
# Insert default rows
rows = [(1, &#39;Bob&#39;, 35, &#39;I like dogs&#39;), (2, &#39;Kim&#39;, 27, &#39;I like birds&#39;)]
cur.bindarraysize = 2
cur.setinputsizes(int, 20, int, 100)
cur.executemany(&quot;insert into cx_people(id, name, age, notes) values (:1, :2, :3, :4)&quot;, rows)
con.commit()
# Insert default rows
rows = [(1, &#39;Duke&#39;, 1, &#39;dog&#39;),
        (2, &#39;Pepe&#39;, 2, &#39;bird&#39;),
        (3, &#39;Princess&#39;, 1, &#39;snake&#39;),
        (4, &#39;Polly&#39;, 1, &#39;bird&#39;),
        (5, &#39;Rollo&#39;, 1, &#39;horse&#39;),
        (6, &#39;Buster&#39;, 1, &#39;dog&#39;),
        (7, &#39;Fido&#39;, 1, &#39;cat&#39;)]
cur.bindarraysize = 2
cur.setinputsizes(int, 20, int, 100)
cur.executemany(&quot;insert into cx_pets (id, name, owner, type) values (:1, :2, :3, :4)&quot;, rows)
con.commit()
cur.close()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;span class=&quot;fullpost&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;fullpost&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;Boilerplate Template&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span class=&quot;fullpost&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;The template we will be using is:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span class=&quot;fullpost&quot;&gt;
&lt;span class=&quot;fullpost&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre class=&quot;displaycode&quot; style=&quot;background: rgb(247, 247, 247) !important; border: 1px solid rgb(204, 204, 204); clear: right; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, Liberation, fixed, monospace; font-size: 11px; margin-bottom: 6px !important; outline: 0px; overflow: auto; padding: 5px 10px 5px 3px !important; text-align: start; vertical-align: baseline; width: 780px;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;import cx_Oracle
import os
connectString = os.getenv(&#39;db_connect&#39;)
con = cx_Oracle.connect(connectString)
def get_all_rows(label, data_type=&#39;people&#39;):
  # Query all rows
  cur = con.cursor()
  if (data_type == &#39;pets&#39;):
    statement = &#39;select id, name, owner, type from cx_pets order by owner, id&#39;
  else:
    statement = &#39;select id, name, age, notes from cx_people order by id&#39;
  cur.execute(statement)
  res = cur.fetchall()
  print(label + &#39;: &#39;)
  print (res)
  print(&#39; &#39;)
  cur.close()
get_all_rows(&#39;Original Data&#39;)
# Your code here
get_all_rows(&#39;New Data&#39;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;
&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;
For each exercise, replace the “# Your code here” line with your code.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span class=&quot;fullpost&quot; style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;Simple Update&amp;nbsp;&lt;/b&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span class=&quot;fullpost&quot; style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;fullpost&quot; style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span class=&quot;fullpost&quot; style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span class=&quot;fullpost&quot; style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;fullpost&quot; style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;We will perform a simple update that modifies a single record in the cx_people table.  These are the steps performed in the code snippet below.&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span class=&quot;fullpost&quot; style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;ul&gt;&lt;span class=&quot;fullpost&quot; style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Get a &lt;a href=&quot;http://cx-oracle.readthedocs.org/en/latest/cursor.html#cursorobj&quot;&gt;cursor object&lt;/a&gt; from our connection.  We will use this cursor to perform our database operations.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Prepare a SQL UPDATE statement, changing age to 31 for the record with an id of 1.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Execute the statement using bind variables.  (See &lt;a href=&quot;http://learncodeshare.net/2015/06/02/select-crud-using-cx_oracle/&quot;&gt;the R part&lt;/a&gt; of this series for an explanation of bind variables.)&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Commit the &lt;a href=&quot;http://learncodeshare.net/2015/06/26/insert-crud-using-cx_oracle/#transactions&quot;&gt;transaction&lt;/a&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ul&gt;
&lt;/div&gt;
&lt;span class=&quot;fullpost&quot; style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;span class=&quot;fullpost&quot; style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;span class=&quot;fullpost&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre class=&quot;displaycode&quot; style=&quot;background: rgb(247, 247, 247) !important; border: 1px solid rgb(204, 204, 204); clear: right; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, Liberation, fixed, monospace; font-size: 11px; margin-bottom: 6px !important; outline: 0px; overflow: auto; padding: 5px 10px 5px 3px !important; text-align: start; vertical-align: baseline; width: 780px;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;cur = con.cursor()
statement = &#39;update cx_pets set owner = :1 where id = :2&#39;
cur.execute(statement, (1, 6))
con.commit()
print(&#39;Number of rows updated: &#39; + str(cur.rowcount))
print(&#39; &#39;)&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;
When I run this code in my Python session, I see:
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre class=&quot;displaycode&quot; style=&quot;background: rgb(247, 247, 247) !important; border: 1px solid rgb(204, 204, 204); clear: right; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, Liberation, fixed, monospace; font-size: 11px; margin-bottom: 6px !important; outline: 0px; overflow: auto; padding: 5px 10px 5px 3px !important; text-align: start; vertical-align: baseline; width: 780px;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;Original Data:
[(3, &#39;Princess&#39;, 1, &#39;snake&#39;), (4, &#39;Polly&#39;, 1, &#39;bird&#39;), (5, &#39;Rollo&#39;, 1, &#39;horse&#39;), (7, &#39;Fido&#39;, 1, &#39;cat&#39;),
 (1, &#39;Duke&#39;, 2, &#39;dog&#39;), (2, &#39;Pepe&#39;, 2, &#39;bird&#39;), (6, &#39;Buster&#39;, 2, &#39;dog&#39;)]
Number of rows updated: 1
New Data:
[(3, &#39;Princess&#39;, 1, &#39;snake&#39;), (4, &#39;Polly&#39;, 1, &#39;bird&#39;), (5, &#39;Rollo&#39;, 1, &#39;horse&#39;), (6, &#39;Buster&#39;, 1, &#39;dog&#39;),
 (7, &#39;Fido&#39;, 1, &#39;cat&#39;), (1, &#39;Duke&#39;, 2, &#39;dog&#39;), (2, &#39;Pepe&#39;, 2, &#39;bird&#39;)]&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;span class=&quot;fullpost&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;a href=&quot;http://cx-oracle.readthedocs.org/en/latest/cursor.html#Cursor.rowcount&quot;&gt;Cursor.rowcount&lt;/a&gt; will show you the number of rows affected for insert, update and delete statements and the number of rows returned in a select statement.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;fullpost&quot; style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;
Extra Fun 1&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot; style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span class=&quot;fullpost&quot; style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Update Bob’s notes to ‘I like cats’ .

Your results should be:
&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre class=&quot;displaycode&quot; style=&quot;background: rgb(247, 247, 247) !important; border: 1px solid rgb(204, 204, 204); clear: right; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, Liberation, fixed, monospace; font-size: 11px; margin-bottom: 6px !important; outline: 0px; overflow: auto; padding: 5px 10px 5px 3px !important; text-align: start; vertical-align: baseline; width: 780px;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;Original Data:
[(1, &#39;Bob&#39;, 31, &#39;I like dogs&#39;), (2, &#39;Kim&#39;, 27, &#39;I like birds&#39;)]
New Data:
[(1, &#39;Bob&#39;, 31, &#39;I like cats&#39;), (2, &#39;Kim&#39;, 27, &#39;I like birds&#39;)]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;
Answer
&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre class=&quot;displaycode&quot; style=&quot;background: rgb(247, 247, 247) !important; border: 1px solid rgb(204, 204, 204); clear: right; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, Liberation, fixed, monospace; font-size: 11px; margin-bottom: 6px !important; outline: 0px; overflow: auto; padding: 5px 10px 5px 3px !important; text-align: start; vertical-align: baseline; width: 780px;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;cur = con.cursor()
statement = &#39;update cx_people set notes = :1 where id = :2&#39;
cur.execute(statement, (&quot;I like cats&quot;, 1))
con.commit()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;span class=&quot;fullpost&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;
Reset the data&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Now is a good time to run reset_data.py.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;&lt;b&gt;Boilerplate Change&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Change the boilerplate get_all_rows statements to get pet data.
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre class=&quot;displaycode&quot; style=&quot;background: rgb(247, 247, 247) !important; border: 1px solid rgb(204, 204, 204); clear: right; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, Liberation, fixed, monospace; font-size: 11px; margin-bottom: 6px !important; outline: 0px; overflow: auto; padding: 5px 10px 5px 3px !important; text-align: start; vertical-align: baseline; width: 780px;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;get_all_rows(&#39;Original Data&#39;, &#39;pets&#39;)
# Your code here
get_all_rows(&#39;New Data&#39;, &#39;pets&#39;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;span class=&quot;fullpost&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;&lt;b&gt;
Make Sure Your Where Clause is Specific&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;In the above example, notice that we used the id column in our where clause.  For our data set, id is the primary key.  You do not always have to use a primary key, but you should make sure you only update the rows you intend to.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Next, let’s look at updating multiple rows.   We’ll have Bob give his dog Duke to Kim.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Get a &lt;a href=&quot;http://cx-oracle.readthedocs.org/en/latest/cursor.html#cursorobj&quot;&gt;cursor object&lt;/a&gt; from our connection.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;We will use this cursor to perform our database operations.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Prepare a SQL UPDATE statement, changing owner to 2 (Kim) for the records with an owner of 1 (Bob) and a type of ‘dog’.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Execute the statement using bind variables.  (See the R part of this series for an explanation of bind variables.)&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Commit the transaction.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre class=&quot;displaycode&quot; style=&quot;background: rgb(247, 247, 247) !important; border: 1px solid rgb(204, 204, 204); clear: right; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, Liberation, fixed, monospace; font-size: 11px; margin-bottom: 6px !important; outline: 0px; overflow: auto; padding: 5px 10px 5px 3px !important; text-align: start; vertical-align: baseline; width: 780px;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;cur = con.cursor()
statement = &#39;update cx_pets set owner = :1 where owner = :2 and type = :3&#39;
cur.execute(statement, (2, 1, &#39;dog&#39;))
con.commit()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;span class=&quot;fullpost&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;
When I run this code in my Python session, I see:
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre class=&quot;displaycode&quot; style=&quot;background: rgb(247, 247, 247) !important; border: 1px solid rgb(204, 204, 204); clear: right; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, Liberation, fixed, monospace; font-size: 11px; margin-bottom: 6px !important; outline: 0px; overflow: auto; padding: 5px 10px 5px 3px !important; text-align: start; vertical-align: baseline; width: 780px;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;Original Data:
[(1, &#39;Duke&#39;, 1, &#39;dog&#39;), (3, &#39;Princess&#39;, 1, &#39;snake&#39;), (4, &#39;Polly&#39;, 1, &#39;bird&#39;), (5, &#39;Rollo&#39;, 1, &#39;horse&#39;),
 (6, &#39;Buster&#39;, 1, &#39;dog&#39;), (7, &#39;Fido&#39;, 1, &#39;cat&#39;), (2, &#39;Pepe&#39;, 2, &#39;bird&#39;)]
New Data:
[(3, &#39;Princess&#39;, 1, &#39;snake&#39;), (4, &#39;Polly&#39;, 1, &#39;bird&#39;), (5, &#39;Rollo&#39;, 1, &#39;horse&#39;), (7, &#39;Fido&#39;, 1, &#39;cat&#39;),
 (1, &#39;Duke&#39;, 2, &#39;dog&#39;), (2, &#39;Pepe&#39;, 2, &#39;bird&#39;), (6, &#39;Buster&#39;, 2, &#39;dog&#39;)]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;span class=&quot;fullpost&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;
In our example we only used owner and type; assuming that Bob only had one dog, Duke, as it is in our original data.  With the new reset data function, we added a second dog, Buster.  This example is intended to demonstrate what may happen when multiple users are working with the same data set.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In our data, the only unique identifier for cx_pets is id.  Bob may have two dogs, or even two dogs named Duke.  Make sure if you intend to change a specific row you use a unique identifier.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
It also helps to…&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Verify the Number of Affected Rows&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Now let&#39;s give Buster back to Bob.  This time, we will use the unique id column and we will print out the number of rows affected using Cursor.rowcount.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;ul&gt;
&lt;li&gt;Get a cursor object from our connection.  We will use this cursor to perform our database operations.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Prepare a SQL UPDATE statement, changing owner to 1 (Bob) for the records with an id of 6 (Buster).&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Execute the statement using bind variables. (See the R part of this series for an explanation of bind variables.)&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Commit the transaction.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre class=&quot;displaycode&quot; style=&quot;background: rgb(247, 247, 247) !important; border: 1px solid rgb(204, 204, 204); clear: right; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, Liberation, fixed, monospace; font-size: 11px; margin-bottom: 6px !important; outline: 0px; overflow: auto; padding: 5px 10px 5px 3px !important; text-align: start; vertical-align: baseline; width: 780px;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;cur = con.cursor()
statement = &#39;update cx_pets set owner = :1 where id = :2&#39;
cur.execute(statement, (1, 6))
con.commit()
print(&#39;Number of rows updated: &#39; + str(cur.rowcount))
print(&#39; &#39;)&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;
When I run this code in my Python session, I see:
&lt;/span&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre class=&quot;displaycode&quot; style=&quot;background: rgb(247, 247, 247) !important; border: 1px solid rgb(204, 204, 204); clear: right; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, Liberation, fixed, monospace; font-size: 11px; margin-bottom: 6px !important; outline: 0px; overflow: auto; padding: 5px 10px 5px 3px !important; text-align: start; vertical-align: baseline; width: 780px;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;Original Data:
[(3, &#39;Princess&#39;, 1, &#39;snake&#39;), (4, &#39;Polly&#39;, 1, &#39;bird&#39;), (5, &#39;Rollo&#39;, 1, &#39;horse&#39;), (7, &#39;Fido&#39;, 1, &#39;cat&#39;),
 (1, &#39;Duke&#39;, 2, &#39;dog&#39;), (2, &#39;Pepe&#39;, 2, &#39;bird&#39;), (6, &#39;Buster&#39;, 2, &#39;dog&#39;)]
Number of rows updated: 1
New Data:
[(3, &#39;Princess&#39;, 1, &#39;snake&#39;), (4, &#39;Polly&#39;, 1, &#39;bird&#39;), (5, &#39;Rollo&#39;, 1, &#39;horse&#39;), (6, &#39;Buster&#39;, 1, &#39;dog&#39;),
 (7, &#39;Fido&#39;, 1, &#39;cat&#39;), (1, &#39;Duke&#39;, 2, &#39;dog&#39;), (2, &#39;Pepe&#39;, 2, &#39;bird&#39;)]&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;
Cursor.rowcount will show you the number of rows affected for insert, update and delete statements and the number of rows returned in a select statement.&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;Extra Fun 2&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Give all birds to Kim that she doesn’t already have and print the number of affected rows .

Your results should be:
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre class=&quot;displaycode&quot; style=&quot;background: rgb(247, 247, 247) !important; border: 1px solid rgb(204, 204, 204); clear: right; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, Liberation, fixed, monospace; font-size: 11px; margin-bottom: 6px !important; outline: 0px; overflow: auto; padding: 5px 10px 5px 3px !important; text-align: start; vertical-align: baseline; width: 780px;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;Original Data:
[(3, &#39;Princess&#39;, 1, &#39;snake&#39;), (4, &#39;Polly&#39;, 1, &#39;bird&#39;), (5, &#39;Rollo&#39;, 1, &#39;horse&#39;), (6, &#39;Buster&#39;, 1, &#39;dog&#39;),
 (7, &#39;Fido&#39;, 1, &#39;cat&#39;), (1, &#39;Duke&#39;, 2, &#39;dog&#39;), (2, &#39;Pepe&#39;, 2, &#39;bird&#39;)]
Number of rows updated: 1
New Data:
[(3, &#39;Princess&#39;, 1, &#39;snake&#39;), (5, &#39;Rollo&#39;, 1, &#39;horse&#39;), (6, &#39;Buster&#39;, 1, &#39;dog&#39;), (7, &#39;Fido&#39;, 1, &#39;cat&#39;),
 (1, &#39;Duke&#39;, 2, &#39;dog&#39;), (2, &#39;Pepe&#39;, 2, &#39;bird&#39;), (4, &#39;Polly&#39;, 2, &#39;bird&#39;)]&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;span class=&quot;fullpost&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;
Answer
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre class=&quot;displaycode&quot; style=&quot;background: rgb(247, 247, 247) !important; border: 1px solid rgb(204, 204, 204); clear: right; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, Liberation, fixed, monospace; font-size: 11px; margin-bottom: 6px !important; outline: 0px; overflow: auto; padding: 5px 10px 5px 3px !important; text-align: start; vertical-align: baseline; width: 780px;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;cur = con.cursor()
statement = &#39;update cx_pets set owner = :1 where type = :2 and owner != :3&#39;
cur.execute(statement, (2, &#39;bird&#39;, 2))
con.commit()
print(&#39;Number of rows updated: &#39; + str(cur.rowcount))
print(&#39; &#39;)&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;span class=&quot;fullpost&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;
Some other things you could try&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Change multiple column values.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Perform an update that changes all rows, if the row count is greater than 2, rollback the change.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/2626804737793090532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2016/05/basic-crud-operations-using-cxoracle.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/2626804737793090532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/2626804737793090532'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2016/05/basic-crud-operations-using-cxoracle.html' title='Basic CRUD Operations Using cx_Oracle, Part 4: Update'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2oIO4XNet0G4pFnBTktXaHY6G4X6ulnKTUbZB63Z0xRPiyx1VRmNhGY5TmvZyAYyUUpjkHzqucNJMhyphenhyphenhlkIIFKV9oqgXFBk_AehikFvji7Vq1_gRusWBFsfV1KKjXi1tQuXi_ylgyx3c/s72-c/python.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-6280440097351805634</id><published>2015-03-03T03:29:00.001-08:00</published><updated>2015-03-03T03:29:02.505-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="VB.Net"/><title type='text'></title><content type='html'>&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;Bind Variable SQL Server with Dot Net&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTDrPgPMJ3X_BZQwX9SlWaflHewldRnVcsa002xYgGPOI2vumMff-YaP7k40sBPxCjo_7SbzWk4tkWGdILN7MHx7T2Uy9zJdtAv6vb86MWz8Bau5KRo_BLt4cSmpKX2Lo0FXT3IPlgLAs/s1600/dotnet.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTDrPgPMJ3X_BZQwX9SlWaflHewldRnVcsa002xYgGPOI2vumMff-YaP7k40sBPxCjo_7SbzWk4tkWGdILN7MHx7T2Uy9zJdtAv6vb86MWz8Bau5KRo_BLt4cSmpKX2Lo0FXT3IPlgLAs/s1600/dotnet.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;If you&#39;ve been developing applications on SQL Server for while, you&#39;ve no doubt come across the concept of &amp;nbsp;&quot;&lt;b&gt;Bind Variable&lt;/b&gt;&quot;. Bind variables are one of those Dot Net concepts that experts frequently cite as being key to application performance, but it&#39;s often not all that easy to pin down exactly what they are and you need to alter your programming style to use them.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;When you use SQL to communicate data between your web application and a database, you have the option to include the literal data in an SQL statement or use bind variables. Bind variables are placeholders for actual values in SQL statements. Writing SQL statements with bind variables rather than substitution variables or literals minimizes processing time and can improve application performance by 20 to 30 percent. Using bind variables can also help prevent an SQL injection attack.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;This article compares the performance and security benefits of using bind variables (also known as bind parameters or dynamic parameters) rather than substitution variables or literals in SQL statements. I briefly introduce bind variables, then demonstrate how they&#39;re used in SQL statements and show the resulting performance improvement. I also show you how to use bind variables to effectively deter an SQL injection attack in a sample Java application.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;fullpost&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Overview of bind variables&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;A &lt;i&gt;bind variable&lt;/i&gt; consists of a variable indicated by a placeholder character such as a question mark (?), :name, or @name. The placeholder character depends on the SQL database server that you use. You provide the actual value of the placeholder at runtime, just before the SQL statement is executed.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;How bind variables improve application performance&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;In most relational databases, an SQL statement is processed in three steps:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;&lt;span class=&quot;fullpost&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Parsing the SQL&lt;/b&gt; statement: Verifies the SQL statement syntax and access rights and builds the best (optimized) execution plan for the SQL statement. Placeholder variables are not known at this point.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Binding variables&lt;/b&gt;: Where the API provides the actual values for placeholders.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Execution&lt;/b&gt;: Done with the selected execution plan and actual value of the placeholder variables.&lt;/span&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ol&gt;
&lt;span class=&quot;fullpost&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Each time an SQL statement is sent to a database, an exact text match is performed to see if the statement is already present in the shared pool. If no matching statement is found, the database performs a hard parse of that statement. If a matching statement is found, then the database initiates a soft parse.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;In a &lt;b&gt;hard parse&lt;/b&gt;, the SQL statement needs to be parsed, checked for syntax errors, checked for correctness of table names and column names, and optimized to find the best execution plan.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;In a &lt;b&gt;soft parse&lt;/b&gt;, the SQL statement already exists in a shared pool, so very little processing is required for access rights and session verification.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Using bind variables enables soft parsing, which means that less processing time is spent on choosing an optimized execution plan. Information about how to process the SQL statement has been saved, along with the SQL statement itself, in a shared pool.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;i&gt;Sample&lt;/i&gt; :&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;pre class=&quot;displaycode&quot; style=&quot;background: rgb(247, 247, 247) !important; border: 1px solid rgb(204, 204, 204); clear: right; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, Liberation, fixed, monospace; font-size: 11px; margin-bottom: 6px !important; outline: 0px; overflow: auto; padding: 5px 10px 5px 3px !important; text-align: start; vertical-align: baseline; width: 780px;&quot;&gt;DECLARE @IntVariable int;
DECLARE @SQLString nvarchar(500);
DECLARE @ParmDefinition nvarchar(500);

/* Build the SQL string one time.*/
SET @SQLString =
     N&#39;SELECT BusinessEntityID, NationalIDNumber, JobTitle, LoginID
       FROM AdventureWorks2008R2.HumanResources.Employee 
       WHERE BusinessEntityID = @BusinessEntityID&#39;;
SET @ParmDefinition = N&#39;@BusinessEntityID tinyint&#39;;
/* Execute the string with the first parameter value. */
SET @IntVariable = 197;
EXECUTE sp_executesql @SQLString, @ParmDefinition,
                      @BusinessEntityID = @IntVariable;
/* Execute the same string with the second parameter value. */
SET @IntVariable = 109;
EXECUTE sp_executesql @SQLString, @ParmDefinition,
                      @BusinessEntityID = @IntVariable;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/6280440097351805634/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2015/03/bind-variable-sql-server-with-dot-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/6280440097351805634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/6280440097351805634'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2015/03/bind-variable-sql-server-with-dot-net.html' title=''/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTDrPgPMJ3X_BZQwX9SlWaflHewldRnVcsa002xYgGPOI2vumMff-YaP7k40sBPxCjo_7SbzWk4tkWGdILN7MHx7T2Uy9zJdtAv6vb86MWz8Bau5KRo_BLt4cSmpKX2Lo0FXT3IPlgLAs/s72-c/dotnet.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-100567810388849528</id><published>2014-11-12T22:28:00.001-08:00</published><updated>2014-11-12T22:29:28.048-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>We hit the Speed limit of python (Peer closed the socket connection)</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;P&lt;/span&gt;&lt;/b&gt;ython is a beautiful language but we know the limitations of the python compared with compiled language. So here I&#39;m explaining a scenario where python was not the ideal choice.

We are using python for network programming, specifically a TCP client/server program which read packets from another C based server. We picked python because on the requirements the traffic volume wasn&#39;t huge enough to consider compiled languages like C/C++ or Java, and we are already using python so more comfortable with it.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span class=&quot;fullpost&quot; style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;b&gt;The Network Topology&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot; style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The data flowing from Server A to Server B via TCP. The Server B is implemented in python for now. This setup was running for more than a year without any problems or crashing. Then it started showing problems. The Server B crashing sometime because of the socket connection between the Server A and Server B getting closed by the Server A, We don&#39;t know why. Bellow listed are the errors that we are getting, one interesting thing is;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;these two errors won&#39;t happen together, some time Errno 104, some time Errno 107.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Errno: 104 - Peer closed the socket connection.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Errno: 107 - Transport endpoint closed.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;I initially thought this was happening because of python&#39;s long running process exiting due to memory overflow or some other reasons. We thought this because python&#39;s reputation as a long running daemon is not great. Then we figure out that long running daemon wasn&#39;t the reason for this issue, since the main python process wasn&#39;t consuming more RAM and it&#39;s very stable in memory usage. Our python server using very simple data structures, so python VM very efficiently handling the Memory.

Then I started to look into other areas of program, by changing the settings and tuning parameters to see any of it fixes the issue. All of the options seems to work for a while but it throws the same error after few days. I was stuck and no idea about the issue and spend around a week to go through the program&#39;s in and out to see any possible causes. But no clue from it.

Finally Stack Overflow came into help, IRC wasn&#39;t helpful for these type of very specific issues. Programmers can&#39;t live without Google and Stack Overflow. I put the question on the SO, people helped me to make the question better by adding the TCP traces picked up using tcpdump. With in hours I got the answer I was looking for. It&#39;s mainly due the python socket reading related. In the Python side we are not clearing the TCP packets from the receive buffer of TCP socket completely, only reading few bytes (300B to 10KB) at a time. So which causing the Python server to send receive window size flag of TCP protocol as ZERO for multiple times In the heavy traffic period. This might triggering this issue. That was the idea I got from the stack Overflow.

The problem on the python side is that, it&#39;s a single threaded server which reading the data from the socket, one thing we are right now not doing is reading until socket is empty due to some implementation restrictions. From the SO answer I got some quick solutions to try,

Remove unwanted codes from the main loop, so the total time taken to process one socket read would be as small as possible.
Tweak with the Kernel parameters for the TCP sending and receiving buffer size.
Improve the Code base or re-implement it in C completely or do the main part as C extension.
The method 1 and 2 was easy go ahead with, So I did it right away. It gives considerable difference and the crashes reduced considerably. But still it happened once or twice. So I know that it&#39;s not enough and need reimplementation of the parts which causing this problem. But we are holding on the reimplementation since it will take lot of time to change the existing stuff. Any way the current changes give enough time to try more things to improve the existing code and investigate the problem more.

Mean while I did some more investigation locally to understand the issue more. From that what I understood was, when the network is heavily loaded the Python server side not clearing the traffic quick enough and which forcing the remote server to close the TCP socket (Not yet found why it&#39;s closing it). Right after the socket is closed on the remote end, Python side of the code might be trying socket.send or socket.recv and it will fail since no active socket. So in the beginning I mentioned that I&#39;m getting two errors, this is because some time right after the remote server closed the socket, the next socket interaction in the python side may be socket.send which was triggering the error Errno 104. If it was socket.recv it would have been Errno 107.

One other thing I learned after this was that, the TCP server usually handles the slow remote servers by blocking the new massage write into the sending buffer. In my environment I understood the remote server A is not blocking the write(Non-blocking socket) instead closing the socket( This could be due to timeout).If the TCP server has option to cache the extra packets into disk then it could have handled this peak traffic period.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;b&gt;A TCP Server has to provide atleast these features&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Way to handle the buffer overflow if the client is very slow.
Write the buffer overflowed data into durable queue or file system.
When the Client comes back, the server has to automatically deliver the pending messages in FIFO order.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;b&gt;Final Thoughts&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;If these options are there with the TCP server that I was handling, this problem couldn&#39;t have happened. So finally now I can say that Python could have handled this situation if the traffic spikes some times only - In our case that was the situation. Python couldn&#39;t have done it if the rate of server is more than the rate at which Python can clear the socket backlog.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Reference by: &lt;a href=&quot;http://haridas.in/what-happens-when-we-hit-the-speed-limit-of-python.html&quot;&gt;http://haridas.in/what-happens-when-we-hit-the-speed-limit-of-python.html&lt;/a&gt;&lt;/span&gt;


&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/100567810388849528/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2014/11/we-hit-speed-limit-of-python-peer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/100567810388849528'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/100567810388849528'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2014/11/we-hit-speed-limit-of-python-peer.html' title='We hit the Speed limit of python (Peer closed the socket connection)'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-3616696849466977419</id><published>2014-07-02T19:54:00.001-07:00</published><updated>2014-07-02T19:54:52.700-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'></title><content type='html'>&lt;h1 style=&quot;background-color: #333333; border: 0px; color: white; display: inline-block; font-family: &#39;Open Sans&#39;, &#39;Lucida Grande&#39;, Tahoma, Verdana, sans-serif; font-size: 28px; font-weight: 300; line-height: 32px; margin: 0px; padding: 0px; text-shadow: rgba(0, 0, 0, 0.2) 0px 1px 1px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;
Cython - Making Python as Fast as C&lt;/h1&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: #333333; border: 0px; color: rgba(255, 255, 255, 0.498039); display: inline-block; font-family: &#39;Open Sans&#39;, &#39;Lucida Grande&#39;, Tahoma, Verdana, sans-serif; font-size: 24px; font-weight: 300; line-height: 32px; margin: 0px; padding: 0px; text-shadow: rgba(0, 0, 0, 0.2) 0px 1px 1px; vertical-align: baseline;&quot;&gt;
by&amp;nbsp;&lt;a href=&quot;https://speakerdeck.com/mosky&quot; style=&quot;border: 0px; color: #339966; font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot;&gt;Mosky&lt;/a&gt;&lt;/h2&gt;
&lt;span class=&quot;fullpost&quot;&gt;




&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;script async=&quot;&quot; class=&quot;speakerdeck-embed&quot; data-id=&quot;6418dd90adda013183613ab2b4f1ac72&quot; data-ratio=&quot;1.33333333333333&quot; src=&quot;//speakerdeck.com/assets/embed.js&quot;&gt;&lt;/script&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/3616696849466977419/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2014/07/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/3616696849466977419'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/3616696849466977419'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2014/07/blog-post.html' title=''/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-2869227087090497230</id><published>2012-04-25T09:41:00.002-07:00</published><updated>2012-04-25T09:41:55.316-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Compile Python Code</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
hohoho,.......&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
This should have been done a long time to execute if the python in the compiled file, to make the file more quickly if the execution. Python source code is automatically compiled into Python byte code by the CPython interpreter. Compiled code is usually stored in PYC (or PYO) files, and is regenerated when the source is updated, or when otherwise necessary.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Python automatically compiles Python source code when you import a module, so the easiest way to create a PYC file is to import it. If you have a module &lt;strong&gt;sampleModule.py&lt;/strong&gt;, just do:&lt;br /&gt;&lt;strong&gt;&amp;gt;&amp;gt;&amp;gt; import
sampleModule&lt;/strong&gt;
 &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
to create a &lt;strong&gt;sampleModule.pyc&lt;/strong&gt; file in the same directory.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
To do this programmatically, and without executing the code, you can use the &lt;strong&gt;&lt;em&gt;py_compile&lt;/em&gt;&lt;/strong&gt; module:&lt;br /&gt;&lt;strong&gt;&amp;gt;&amp;gt;&amp;gt;import py_compile&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&amp;gt;&amp;gt;&amp;gt;py_compile.compile(&quot;fileModule.py&quot;)&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;There’s also a compileall module which can be used to compile all modules in an entire directory tree.&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt;&lt;strong&gt;import compileall&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&amp;gt;&amp;gt;&amp;gt;compileall.compile_dir(&quot;folderDestination&quot;, force=1)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Good luck, :)&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;




&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/2869227087090497230/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2012/04/compile-python-code.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/2869227087090497230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/2869227087090497230'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2012/04/compile-python-code.html' title='Compile Python Code'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>0</thr:total><georss:featurename>Jalan Raya Serpong, Serpong, Indonesia</georss:featurename><georss:point>-6.31734 106.663691</georss:point><georss:box>-6.3489045 106.624209 -6.2857755 106.703173</georss:box></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-2134059590456867380</id><published>2011-10-25T08:53:00.000-07:00</published><updated>2011-10-25T08:53:16.699-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="VB.Net"/><title type='text'>Overloading</title><content type='html'>&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;Can not believe it for an overloading in programming OOP (Object Oriented Programming), It was very in need in a class called repeatedly with different parameters in the same class and the same method, it does not mean overriding. As in VB.Net:&lt;/div&gt;&lt;script src=&quot;https://gist.github.com/1313159.js?file=gistfile1.txt&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;     &lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;different from the python, in python there are several constructors, but it&#39;s rather difficult when compared to Java or Dot Net. like the __init__ constructor, the constructor can not be overloading the constructor of the same name before, just be overloading the operator or by the same constructor, but do not know in their use?&lt;/span&gt;&lt;br style=&quot;font-family: Arial,Helvetica,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt; misalnya seperti :&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;class com:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;def __init__(self):&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;print &quot;original constructor&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;def __init__(self, val1):&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;print &quot;second overloading&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;def __init__(self, val1, val2):&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;print &quot;thrid overload&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;this is wrong. &lt;/span&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;because&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;in python&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;does not apply&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;any such provisions&lt;/span&gt;&lt;span class=&quot;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;What about python? &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/2134059590456867380/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2011/10/overloading.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/2134059590456867380'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/2134059590456867380'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2011/10/overloading.html' title='Overloading'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-4989468721972105500</id><published>2011-09-21T23:59:00.000-07:00</published><updated>2011-09-21T23:59:36.777-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Overview of PyPy</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;This may be foreign to you, but this is a fact. PyPy is a Python programming language interpreter written in Python and is equipped with a JIT compiler (just in time). PyPy development focuses on the speed of program performance, efficiency, and maintain compatibility with CPython interpreter. Using Python in PyPy development, the developers PyPy allows hacking of its implementation and identify any areas that require improvement. PyPy fact currently implemented as a high level language makes it more flexible and easier in the experiment when compared to CPython, and also allows developers to experiment on some form of implementation of certain specific features.&lt;br /&gt;
&lt;br /&gt;
PyPy translation model also provides a general framework for developing and supporting forms to create a dynamic programming language, providing a clear separation between the specification of a programming language with aspects and forms of implementation. In addition, the PyPy provides a programming language Python that is compatible with CPython with the flexibility and level of performance is better.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;b&gt;whether it can be concluded that the programming language compilers much faster?&lt;/b&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;     &lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/4989468721972105500/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2011/09/overview-of-pypy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/4989468721972105500'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/4989468721972105500'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2011/09/overview-of-pypy.html' title='Overview of PyPy'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-3893257144689757527</id><published>2011-03-20T08:41:00.000-07:00</published><updated>2011-03-20T08:41:24.349-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Read an XML file in Java</title><content type='html'>For previously been discussed about how to convert data to xml, we now discuss for how to parse xml. This is a simple way for parsing the xml file.&lt;br /&gt;
The following example code :&lt;br /&gt;
&lt;b&gt;XML File :&lt;/b&gt;&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/878382.js?file=XMLOuput&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;b&gt;Output      :&lt;/b&gt;&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/878386.js?file=output&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt; &lt;br /&gt;
&lt;b&gt;Java Code:&lt;/b&gt;&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/878380.js?file=parsingXML&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
There are better implementations of reading XML files which would work for any XML file. The above one would require a few changes every time the XML tag names change. But this is much more simpler than the other programs.&lt;br /&gt;
&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/3893257144689757527/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2011/03/read-xml-file-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/3893257144689757527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/3893257144689757527'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2011/03/read-xml-file-in-java.html' title='Read an XML file in Java'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-8701083802588549703</id><published>2011-02-23T08:20:00.000-08:00</published><updated>2011-02-23T08:24:17.333-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Entity on Programming</title><content type='html'>&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;Entity is an object whose existence can be distinguished against other objects. Entities can be people, objects, places, events, concepts. Example :&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;ul style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;li&gt;People: STUDENTS, LECTURERS, SUPPLIER, VENDOR&lt;/li&gt;
&lt;li&gt;Objects: CAR, ENGINE, ROOM&lt;/li&gt;
&lt;li&gt;Venue: THE STATE, THE VILLAGE, KAMPONG&lt;/li&gt;
&lt;li&gt;Genesis: SALES, REGISTER&lt;/li&gt;
&lt;li&gt;Concept: ACCOUNT, COURSE  &lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;An entity has a number of attributes&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;Example: The student has the name and address&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;Entity set is aa set of entities that share the same attributes  &lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt; In programming OOP (Object Oriented Programming) or object-oriented Programming is a new way of thinking and logic in dealing with the problems that will try to overcome with the help of computers. OOP, unlike its predecessor (Structured Programming), trying to see problems through observation of the real world where every object is a single entity that has a combination of data structures and specific functions. This contrasts with structured programming where data structures and functions are defined separately and are not closely related.&lt;br /&gt;
it can be explained in the following code fragment:&lt;br /&gt;
&lt;br /&gt;
in Python&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/840625.js?file=Entity_python&quot;&gt;&lt;/script&gt;&lt;br /&gt;
in Java&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/840639.js?file=Entitas_Java&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
hopefully useful for those who love OOP&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/8701083802588549703/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2011/02/entity-on-programming.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/8701083802588549703'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/8701083802588549703'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2011/02/entity-on-programming.html' title='Entity on Programming'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-1010946547399164074</id><published>2011-01-31T08:48:00.000-08:00</published><updated>2011-01-31T08:55:55.648-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Create File XML</title><content type='html'>&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;&lt;b&gt;Extensible Markup Language (XML)&lt;/b&gt; is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications.&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;The material in this section is based on the XML Specification. This is not an exhaustive list of all the constructs which appear in XML; it provides an introduction to the key constructs most often encountered in day-to-day use. XML documents may begin by declaring some information about themselves, as in the following example.&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;&lt;script src=&quot;https://gist.github.com/804250.js?file=header_xml&quot;&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;In Java, two built-in XML parsers are available – DOM and SAX, both have their pros and cons. Here’s few examples to show how to create, modify and read a XML file with Java DOM, SAX and JDOM xml parser.&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;The DOM interface is the easiest to understand. It parses an entire XML document and load it into memory, modeling it with Object for the traversal. DOM Parser is slow and consume a lot memory if it load a XML document which contains a lot of data. &lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;now we try to create XML files using XML DOM Parser.&lt;/div&gt;&lt;span class=&quot;fullpost&quot;&gt; &lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/804297.js?file=xmlfile&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;results :&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/804316.js?file=resultXML&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;XML file can be edited for each element in its node can query the results table. XML file from the query table.&lt;/span&gt;&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/804338.js?file=xmlQuery&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/1010946547399164074/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2011/01/create-file-xml.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/1010946547399164074'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/1010946547399164074'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2011/01/create-file-xml.html' title='Create File XML'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-5534335895891401840</id><published>2010-12-11T08:18:00.000-08:00</published><updated>2010-12-11T08:18:44.285-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Try to JTree</title><content type='html'>&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;Time for us to play with JTree, and how to take the label of the JTree. We try to connect your with MySql database, and read all the databases, tables, and each column name.&lt;/div&gt;&lt;script src=&quot;https://gist.github.com/737440.js?file=JTreeNow&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;     &lt;br /&gt;
&lt;span style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;Screen :&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinEomF5opI8cmIPRx6hchja-WBtYJJLGZ839OLofMiBQEj6Kc39tLfEsqOjsAOuB6TMYaGD69PvSOd1_ZbYSvism6rtw23d6TEj0NWWjdOoXo0PDdNV4IUvUz_TbYYB619zfDmHhauu_E/s1600/JTree.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;318&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinEomF5opI8cmIPRx6hchja-WBtYJJLGZ839OLofMiBQEj6Kc39tLfEsqOjsAOuB6TMYaGD69PvSOd1_ZbYSvism6rtw23d6TEj0NWWjdOoXo0PDdNV4IUvUz_TbYYB619zfDmHhauu_E/s320/JTree.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/5534335895891401840/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2010/12/try-to-jtree.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/5534335895891401840'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/5534335895891401840'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2010/12/try-to-jtree.html' title='Try to JTree'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinEomF5opI8cmIPRx6hchja-WBtYJJLGZ839OLofMiBQEj6Kc39tLfEsqOjsAOuB6TMYaGD69PvSOd1_ZbYSvism6rtw23d6TEj0NWWjdOoXo0PDdNV4IUvUz_TbYYB619zfDmHhauu_E/s72-c/JTree.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-2226332857741341946</id><published>2010-12-03T00:04:00.000-08:00</published><updated>2010-12-03T00:18:18.863-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Call Font Face into ComboBox</title><content type='html'>&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span title=&quot;&quot;&gt;Long time no write off my blog. &lt;/span&gt;&lt;span title=&quot;&quot;&gt;Today wanted to write, how to call the font and inserted into the ComboBox in Java. &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span title=&quot;&quot;&gt;Code more or less like this:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span title=&quot;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;script src=&quot;https://gist.github.com/726693.js?file=FontIntoComboBox&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;b&gt;output :&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgupR37UGvnNz5nUHwUb5H4aIkOwlhI8E8a_nCF4TP_4XVBsr9e6beBMtYq0Ptu7cRgtot7w3gVp4q4QnZQCscR-Og8ZoSSZmpvpBYpINPcSeMadsvTd4_lcMIhbgnFEfTglEpgpLSNAIY/s1600/font.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgupR37UGvnNz5nUHwUb5H4aIkOwlhI8E8a_nCF4TP_4XVBsr9e6beBMtYq0Ptu7cRgtot7w3gVp4q4QnZQCscR-Og8ZoSSZmpvpBYpINPcSeMadsvTd4_lcMIhbgnFEfTglEpgpLSNAIY/s320/font.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span title=&quot;&quot;&gt;if you trouble in making the GUI in Java, you can use Jigloo to help make the creation GUI.&lt;/span&gt;&lt;/span&gt;&lt;b&gt; &lt;/b&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span title=&quot;&quot;&gt;Congratulations to give it a try.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/2226332857741341946/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2010/12/call-font-face-into-combobox.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/2226332857741341946'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/2226332857741341946'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2010/12/call-font-face-into-combobox.html' title='Call Font Face into ComboBox'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgupR37UGvnNz5nUHwUb5H4aIkOwlhI8E8a_nCF4TP_4XVBsr9e6beBMtYq0Ptu7cRgtot7w3gVp4q4QnZQCscR-Og8ZoSSZmpvpBYpINPcSeMadsvTd4_lcMIhbgnFEfTglEpgpLSNAIY/s72-c/font.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-6588232305539475771</id><published>2010-09-22T00:53:00.000-07:00</published><updated>2010-09-22T00:53:39.394-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Connection Python to SQLite</title><content type='html'>&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;&lt;b&gt;S&lt;/b&gt;QLite is a in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. The code for SQLite is in the public domain and is thus free for use for any purpose, commercial or private. SQLite is currently found in more applications than we can count, including several high-profile projects.&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;SQLite is an embedded SQL database engine. Unlike most other SQL databases, SQLite does not have a separate server process. SQLite reads and writes directly to ordinary disk files. A complete SQL database with multiple tables, indices, triggers, and views, is contained in a single disk file. The database file format is cross-platform - you can freely copy a database between 32-bit and 64-bit systems or between big-endian and little-endian architectures.&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;The &lt;a href=&quot;http://www.sqlite.org/&quot;&gt;SQLite&lt;/a&gt; library is a light-weight embedded SQL engine, with a nice &lt;a href=&quot;http://www.python.org/dev/peps/pep-0249/&quot;&gt;DB-API&lt;/a&gt; compliant &lt;a href=&quot;http://pysqlite.sourceforge.net/&quot;&gt;Python binding&lt;/a&gt;, originally developed by Michael Owens.&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;A newer version, called sqlite3, was added to Python’s standard library in Python 2.5 to up.&lt;/div&gt;&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;script src=&quot;http://gist.github.com/591323.js?file=SQLitePython&quot;&gt;
&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/6588232305539475771/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2010/09/connection-python-to-sqlite.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/6588232305539475771'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/6588232305539475771'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2010/09/connection-python-to-sqlite.html' title='Connection Python to SQLite'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-7028541858127772856</id><published>2010-05-24T01:30:00.000-07:00</published><updated>2010-05-24T01:45:00.334-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Pythagorean Theorem</title><content type='html'>If you are on school and you are taking algebra like me or just want to find the missing length of one side of the triangle than this program should help you out. Pythagorean Theorem is great and extremely essay to use. &lt;br /&gt;
We can find the side of a triangle using the Pythagorean algorithm. This uses the Python programming language.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;def menu():&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#print the options you have&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print &quot; &quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print &quot;Welcome to Pythagorean Theorem&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print &quot;Please keep in mind that for this program to work you need the lenght of two side of the triangle&quot; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print &quot; &quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print &quot;Your Options Are:&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print &quot; &quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print &quot;1) If you have the lenght of A and B&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print &quot; &quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print &quot;2) If you have the lenght of C and A&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print &quot; &quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print &quot;3) If you have the lenght of C and B&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print &quot; &quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print &quot;4) Quit Pythagorean Theorem&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print &quot; &quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return input (&quot;Choose your option: &quot;)&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
from math import *&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#On this one we have the lenght of A and B and we are trying to find the lenght of C&lt;br /&gt;
def AnB(a,b):&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print a**2, &quot;+&quot;, b**2, &quot;=&quot;, a**2 + b**2&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print sqrt(a**2 + b**2)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#On this one we have the lenght of A and C and we are trying to find the lenght of B&lt;br /&gt;
def CnA(c,a):&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print c**2, &quot;-&quot;, a**2, &quot;=&quot;, c**2 - a**2&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print sqrt(c**2 - a**2)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#On this one we have the lenght of B and C and we are trying to find the lenght of A&lt;br /&gt;
def CnB(c,b):&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print c**2, &quot;-&quot;, b**2, &quot;=&quot;, c**2 - b**2&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print sqrt(c**2 - b**2)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#Code is Run&lt;br /&gt;
loop = 1&lt;br /&gt;
choice = 0&lt;br /&gt;
while loop == 1:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;choice = menu()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if choice == 1:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;AnB(input(&quot;A: &quot;),input(&quot;B: &quot;))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;elif choice == 2:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CnA(input(&quot;C: &quot;),input(&quot;A: &quot;))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;elif choice == 3:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CnB(input(&quot;C: &quot;),input(&quot;B: &quot;))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;elif choice == 4:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;loop = 0&lt;br /&gt;
print &quot;Thankyou fo using Pythagorean Theorem&quot;&lt;/blockquote&gt;&lt;a target=&quot;_blank&quot;  href=&quot;http://www.amazon.com/Honest-Face/dp/B002HP8EKE?ie=UTF8&amp;tag=iniadalahsuat-20&amp;link_code=btl&amp;camp=213689&amp;creative=392969&quot;&gt;Honest Face&lt;/a&gt;&lt;img src=&quot;http://www.assoc-amazon.com/e/ir?t=iniadalahsuat-20&amp;l=btl&amp;camp=213689&amp;creative=392969&amp;o=1&amp;a=B002HP8EKE&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important; padding: 0px !important&quot; /&gt;&lt;br /&gt;
&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/7028541858127772856/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2010/05/pythagorean-theorem.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/7028541858127772856'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/7028541858127772856'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2010/05/pythagorean-theorem.html' title='Pythagorean Theorem'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-7001807452538052517</id><published>2010-04-22T04:15:00.000-07:00</published><updated>2010-04-22T07:27:11.859-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Class Inheritance</title><content type='html'>&lt;strong&gt;Use __class__, __bases__ and __dict__ for sub and super class&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align=&quot;justify&quot;&gt;inheritance learn python programming language, Python is very simple. Now using __class__, __bases__ and __dict__ for sub and super class. Try making a super class and child class. Examples like this:&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;class &lt;span&gt;super&lt;/span&gt;:&lt;br /&gt;         def hello(self):&lt;br /&gt;                   self.data1 = &#39;spam&#39;&lt;br /&gt;&lt;br /&gt;class sub(&lt;span&gt;super&lt;/span&gt;):&lt;br /&gt;         def hola(self):&lt;br /&gt;                    self.data2 = &#39;eggs&#39;&lt;br /&gt;&lt;br /&gt;X = sub()&lt;br /&gt;X.__dict__&lt;br /&gt;{}&lt;br /&gt;&lt;br /&gt;print X.__class__&lt;br /&gt;&lt;br /&gt;print sub.__bases__&lt;br /&gt;&lt;br /&gt;print super.__bases__&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Y = sub()&lt;br /&gt;&lt;br /&gt;X.hello()&lt;br /&gt;print X.__dict__&lt;br /&gt;&lt;br /&gt;X.hola()&lt;br /&gt;print X.__dict__&lt;br /&gt;&lt;br /&gt;print sub.__dict__&lt;br /&gt;&lt;br /&gt;print super.__dict__&lt;br /&gt;&lt;br /&gt;print sub.__dict__.keys(), super.__dict__.keys()&lt;br /&gt;&lt;br /&gt;print Y.__dict__&lt;br /&gt;&lt;br /&gt;print X.data1, X.__dict__[&#39;data1&#39;]&lt;br /&gt;&lt;br /&gt;X.data3 = &#39;toast&#39;&lt;br /&gt;print X.__dict__&lt;br /&gt;&lt;br /&gt;X.__dict__[&#39;data3&#39;] = &#39;ham&#39;&lt;br /&gt;print X.data3&lt;br /&gt;&lt;br /&gt;print X.__dict__&lt;br /&gt;print X.__dict__.keys()&lt;br /&gt;&lt;br /&gt;print dir(X)&lt;br /&gt;print  dir(sub)&lt;br /&gt;print dir(super)&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;span&gt;Result&lt;/span&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKB1Setr2J5t6ozjNZNDyDESEYRrBpW8iCHktst1BoSLkbQzu_mm2i2VWs3qC-7VoAQyd-uolLwjgMlrOpIvq6p_mOfE8AMH5WXl-qPCxdCZFxDC95kPhWINItJJ1kiWY2t10_fcwyr0U/s1600/Useclassbasesanddictforsubandsuperclass.PNG&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKB1Setr2J5t6ozjNZNDyDESEYRrBpW8iCHktst1BoSLkbQzu_mm2i2VWs3qC-7VoAQyd-uolLwjgMlrOpIvq6p_mOfE8AMH5WXl-qPCxdCZFxDC95kPhWINItJJ1kiWY2t10_fcwyr0U/s400/Useclassbasesanddictforsubandsuperclass.PNG&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5462921320490920802&quot; /&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/7001807452538052517/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2010/04/class-inheritance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/7001807452538052517'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/7001807452538052517'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2010/04/class-inheritance.html' title='Class Inheritance'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKB1Setr2J5t6ozjNZNDyDESEYRrBpW8iCHktst1BoSLkbQzu_mm2i2VWs3qC-7VoAQyd-uolLwjgMlrOpIvq6p_mOfE8AMH5WXl-qPCxdCZFxDC95kPhWINItJJ1kiWY2t10_fcwyr0U/s72-c/Useclassbasesanddictforsubandsuperclass.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-6394887181243560489</id><published>2010-02-09T23:26:00.000-08:00</published><updated>2010-02-09T23:58:09.144-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>BubbleSort</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size:180%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;A&lt;/span&gt;&lt;/span&gt;lgorithm &lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;BubbleSort&lt;/span&gt; is a simple sorting algorithm, it works by repeatly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps or needed, which indicates that the list is sorted. The algorithm gets its name from the way smaller elements &quot;&lt;span style=&quot;font-style: italic;&quot;&gt;bubble&lt;/span&gt;&quot; to the top of the list.&lt;br /&gt;&lt;/div&gt;For Example :&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;import java.util.*;&lt;br /&gt;&lt;br /&gt;class node1 {&lt;br /&gt;         int data;&lt;br /&gt;         node1 next, prev;&lt;br /&gt;&lt;br /&gt;        public node1(int n) {&lt;br /&gt;                   data = n;&lt;br /&gt;                   next = prev = null;&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;b&gt;//Class list&lt;/b&gt;&lt;br /&gt;class list {&lt;br /&gt;         node1 head, tail;&lt;br /&gt;&lt;br /&gt;         public list() {&lt;br /&gt;                    head = tail = null;&lt;br /&gt;         }&lt;br /&gt;&lt;br /&gt;         void addLast(int n) {&lt;br /&gt;                 node1 input = new node1(n);&lt;br /&gt;                 if (head == null) {&lt;br /&gt;                               head = tail = input;&lt;br /&gt;                 } else {&lt;br /&gt;                               tail.next = input;&lt;br /&gt;                               input.prev = tail;&lt;br /&gt;                               tail = input;&lt;br /&gt;                 }&lt;br /&gt;         }&lt;br /&gt;                &lt;b&gt;// for sorting&lt;/b&gt;&lt;br /&gt;        void sorting() {&lt;br /&gt;                node1 once = head, second = head, vloop = head;&lt;br /&gt;                while (vloop != tail) {&lt;br /&gt;                              once = head;&lt;br /&gt;                              while (once != null) {&lt;br /&gt;                                       second = once.next;&lt;br /&gt;                                       if (second != null) {&lt;br /&gt;                                            if (second.data &lt; once.data)&lt;br /&gt;                                                  vchange(once, second);     &lt;br /&gt;                                      }     once = once.next;    &lt;br /&gt;                            }    vloop = vloop.next;   &lt;br /&gt;                }   &lt;br /&gt;        }   &lt;br /&gt;        void vchange(node1 once, node1 second) {   &lt;br /&gt;                int temp = second.data;   &lt;br /&gt;                second.data = once.data;   &lt;br /&gt;                once.data = temp;  &lt;br /&gt;        }   &lt;br /&gt;        void vprint() {   &lt;br /&gt;                node1 temp = head;   &lt;br /&gt;                while (temp != null) {    &lt;br /&gt;                          System.out.print(temp.data + &quot; &quot;);    &lt;br /&gt;                          temp = temp.next;   &lt;br /&gt;               }  &lt;br /&gt;        } &lt;br /&gt;}&lt;br /&gt;&lt;b&gt;//main class&lt;/b&gt;&lt;br /&gt;public class BubleSort {&lt;br /&gt;           public static void main(String[] args) {&lt;br /&gt;                      Scanner input = new Scanner(System.in);&lt;br /&gt;                      System.out.print(&quot;Total by sorting  : &quot;);&lt;br /&gt;                      int n = input.nextInt();&lt;br /&gt;                      list vnumber = new list();&lt;br /&gt;&lt;br /&gt;                      System.out.println(&quot;Input number :&quot;);&lt;br /&gt;                      for (int i = 0; i &lt; n; i++) {    &lt;br /&gt;                             System.out.print(&quot;&gt;&gt; &quot;);&lt;br /&gt;                             int a = input.nextInt();&lt;br /&gt;                             v_number.addLast(a);&lt;br /&gt;                      }&lt;br /&gt;&lt;br /&gt;                      System.out.println(&quot;Sort by Ascending :&quot;);&lt;br /&gt;                      for (int i = 0; i &lt; n - 1; i++) {    &lt;br /&gt;                             vnumber.sorting();   &lt;br /&gt;                      }   &lt;br /&gt;                      vnumber.vprint();   &lt;br /&gt;                      System.out.println();  &lt;br /&gt;           }&lt;br /&gt;}  &lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/6394887181243560489/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2010/02/bubblesort.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/6394887181243560489'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/6394887181243560489'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2010/02/bubblesort.html' title='BubbleSort'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-3453268484792276127</id><published>2010-02-05T01:14:00.000-08:00</published><updated>2010-02-05T01:20:33.260-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Binary Search</title><content type='html'>Algorithm Binary Search&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;package myPackage;&lt;br /&gt;&lt;br /&gt;import java.util.Scanner;&lt;br /&gt;&lt;br /&gt;class ArrayQ {&lt;br /&gt; int[] data;&lt;br /&gt; int pj;&lt;br /&gt;&lt;br /&gt; public ArrayQ(int ArrayQ) {&lt;br /&gt;  data = new int[ArrayQ];&lt;br /&gt;  pj = 0;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; void insert(int angka) {&lt;br /&gt;  int i;&lt;br /&gt;  for (i = 0; i &lt; pj; i++) {&lt;br /&gt;   if (data[i] &gt; angka)&lt;br /&gt;    break;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  for (int j = pj; j &gt; i; j--) {&lt;br /&gt;   data[j] = data[j - 1];&lt;br /&gt;  }&lt;br /&gt;  data[i] = angka;&lt;br /&gt;  pj++;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; void display() {&lt;br /&gt;  for (int i = 0; i &lt; pj; i++)&lt;br /&gt;   System.out.print(data[i] + &quot; &quot;);&lt;br /&gt;  System.out.println();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; void searching(int key) {&lt;br /&gt;  System.out.println(&quot;\nFind Value Process &quot; + key);&lt;br /&gt;&lt;br /&gt;  int bawah = 0;&lt;br /&gt;  int tengah;&lt;br /&gt;  int atas = pj - 1;&lt;br /&gt;&lt;br /&gt;  while (atas &gt;= bawah) {&lt;br /&gt;   tengah = (bawah + atas) / 2;&lt;br /&gt;   if (data[tengah] == key) {&lt;br /&gt;    System.out.println(&quot;Status : Found!!&quot;);&lt;br /&gt;    return;&lt;br /&gt;   } else {&lt;br /&gt;    if (data[tengah] &lt; key)&lt;br /&gt;     bawah = tengah + 1;&lt;br /&gt;    else&lt;br /&gt;     atas = tengah - 1;&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  System.out.println(&quot;Status : not found!!&quot;);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class BinarySearch2 {&lt;br /&gt; public static void main(String[] args) {&lt;br /&gt;  System.out.println(&quot;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&quot;);&lt;br /&gt;  System.out.println(&quot; Binary Search\n &quot;);&lt;br /&gt;  System.out.println(&quot;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&quot;);&lt;br /&gt;  Scanner input = new Scanner(System.in);&lt;br /&gt;  System.out.print(&quot;Sum Value = &quot;);&lt;br /&gt;  int jumlah = input.nextInt();&lt;br /&gt;&lt;br /&gt;  ArrayQ list;&lt;br /&gt;  list = new ArrayQ(sumValue);&lt;br /&gt;&lt;br /&gt;  System.out.println(&quot;input value :&quot;);&lt;br /&gt;  int[] val = new int[sumValue];&lt;br /&gt;  for (int i = 0; i &lt; sumValue; i++) {&lt;br /&gt;   System.out.print(&quot;&gt;&gt; &quot;);&lt;br /&gt;   val[i] = input.nextInt();&lt;br /&gt;   list.insert(val[i]);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  list.display();&lt;br /&gt;  System.out.println(&quot;\nFind : &quot;);&lt;br /&gt;  int search = input.nextInt();&lt;br /&gt;&lt;br /&gt;  list.searching(search);&lt;br /&gt;  // System.out.println(“Status : Found!!”);&lt;br /&gt;  // System.out.println(“Status : not Found!!”);&lt;br /&gt;&lt;br /&gt;  System.out.println();&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;good luck</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/3453268484792276127/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2010/02/binary-search.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/3453268484792276127'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/3453268484792276127'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2010/02/binary-search.html' title='Binary Search'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-6671460975797527715</id><published>2010-02-05T00:40:00.000-08:00</published><updated>2010-02-05T00:58:38.223-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Search Linier</title><content type='html'>Algorithma Search Linier,...&lt;br /&gt;you can to try&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;package myPackage;&lt;br /&gt;&lt;br /&gt;import java.util.Scanner;&lt;br /&gt;&lt;b&gt;//class node for found index&lt;/b&gt;&lt;br /&gt;class Node {&lt;br /&gt; int data, index;&lt;br /&gt; Node next;&lt;br /&gt;&lt;br /&gt; public Node(int data, int index) {&lt;br /&gt;  this.data = data;&lt;br /&gt;  this.index = index;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;// i&#39;m use linklist&lt;br /&gt;class LinkedList {&lt;br /&gt; Node head, tail;&lt;br /&gt;&lt;br /&gt; void addLast(int nilai, int id) {&lt;br /&gt;  Node input = new Node(nilai, id);&lt;br /&gt;&lt;br /&gt;  if (head == null) {&lt;br /&gt;   head = tail = input;&lt;br /&gt;  } else {&lt;br /&gt;   tail.next = input;&lt;br /&gt;   tail = input;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; void display() {&lt;br /&gt;  Node temp = head;&lt;br /&gt;  while (temp != null) {&lt;br /&gt;   System.out.print(temp.data + &quot; &quot;);&lt;br /&gt;   temp = temp.next;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; void searching(int key) {&lt;br /&gt;  Node temp = head;&lt;br /&gt;  System.out.println(&quot;\nProses Pencarian Angka &quot; + key);&lt;br /&gt;  while (temp != null) {&lt;br /&gt;   if (temp.data == key) {&lt;br /&gt;    System.out.println(&quot;Status : ditemukan di indeks ke-&quot;&lt;br /&gt;      + temp.index);&lt;br /&gt;    break;&lt;br /&gt;   } else&lt;br /&gt;    temp = temp.next;&lt;br /&gt;  }&lt;br /&gt;  if (temp == null)&lt;br /&gt;   System.out.println(&quot;Status : tak ditemukan!!&quot;);&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class LinearSearch {&lt;br /&gt; public static void main(String[] args) {&lt;br /&gt;  System.out.println(&quot;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&quot;);&lt;br /&gt;  System.out.println(&quot; Linear Search\n &quot;);&lt;br /&gt;  System.out.println(&quot;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&quot;);&lt;br /&gt;&lt;br /&gt;  LinkedList list = new LinkedList();&lt;br /&gt;  Scanner input = new Scanner(System.in);&lt;br /&gt;  System.out.print(&quot;Jumlah angka = &quot;);&lt;br /&gt;  int jumlah = input.nextInt();&lt;br /&gt;  input = new Scanner(System.in);&lt;br /&gt;  System.out.println(&quot;Masukkan angka :&quot;);&lt;br /&gt;  int angka;&lt;br /&gt;  for (int i = 0; i &lt; jumlah; i++) {&lt;br /&gt;   System.out.print(&quot;&gt;&gt; &quot;);&lt;br /&gt;   angka = input.nextInt();&lt;br /&gt;   list.addLast(angka, i); // nama team disimpan dalam queue&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  list.display();&lt;br /&gt;  System.out.print(&quot;\nDicari : &quot;);&lt;br /&gt;  int cari = input.nextInt();&lt;br /&gt;  list.searching(cari);&lt;br /&gt;  System.out.println();&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;good luck for you</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/6671460975797527715/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2010/02/search-linier.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/6671460975797527715'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/6671460975797527715'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2010/02/search-linier.html' title='Search Linier'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-3041912984380304275</id><published>2009-12-20T07:29:00.000-08:00</published><updated>2009-12-20T07:51:03.380-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Maximum value 1st, 2nd</title><content type='html'>Maximum value can with method as this code:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;public class Array&lt;br /&gt;{&lt;br /&gt;   public void getMax( double ar[] )&lt;br /&gt;   {&lt;br /&gt;       double max1 = ar[0]; // &lt;span style=&quot;font-weight: bold;&quot;&gt;Assume the first&lt;/span&gt;&lt;br /&gt;       int ZERO = 0; // &lt;span style=&quot;font-weight: bold;&quot;&gt;Variable to store inside it the index of the max value to set it to zero&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;       for( int i = 0; i &lt;&gt;= max1)&lt;br /&gt;           {&lt;br /&gt;               max1 = ar[i];&lt;br /&gt;               ZERO = i;&lt;br /&gt;           }&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       ar[ZERO] = 0; //&lt;span style=&quot;font-weight: bold;&quot;&gt; Set the index contains the 1st max to ZERO&lt;/span&gt;.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;        double max2 = ar[0]; // &lt;span style=&quot;font-weight: bold;&quot;&gt;element in the array&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;       for( int j = 0; j &lt;&gt;= max2 )&lt;br /&gt;           {&lt;br /&gt;               max2 = ar[j];&lt;br /&gt;               ZERO = j;&lt;br /&gt;           }&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       System.out.println(&quot;The 1st maximum element in the array is: &quot; + max1 + &quot;, the 2nd is: &quot; + max2);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public static void main(String[] args)&lt;br /&gt;   {&lt;br /&gt;       // &lt;span style=&quot;font-weight: bold;&quot;&gt;Creating an object from the class Array to be able to use its methods.&lt;/span&gt;&lt;br /&gt;       Array myArray = new Array();&lt;br /&gt;       // &lt;span style=&quot;font-weight: bold;&quot;&gt;Creating an array of type double.&lt;/span&gt;&lt;br /&gt;       double a[] = {6.6,2.2, 3.4, 5.5, 5.5, 5.6};&lt;br /&gt;&lt;br /&gt;       &lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span class=&quot;fullpost&quot;&gt;myArray&lt;/span&gt;.getMax( a ); // &lt;span style=&quot;font-weight: bold;&quot;&gt;Calling the method that&#39;ll find the 1st max, 2nd max.&lt;/span&gt;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;This code can increase with Array 3nd etc.</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/3041912984380304275/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2009/12/maximum-value-1st-2nd.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/3041912984380304275'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/3041912984380304275'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2009/12/maximum-value-1st-2nd.html' title='Maximum value 1st, 2nd'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-1955650928530192003</id><published>2009-11-05T23:53:00.000-08:00</published><updated>2009-11-06T00:07:53.581-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>A simple Login with Dictionary (Python)</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;Just a Simple login that uses Dictionary. Don&#39;t know if it work on a console. Plus i can&#39;t figure out a way to add something to the dictionary while the program is running.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;&lt;span class=&quot;n&quot;&gt;database&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&#39;username&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&#39;1234&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&#39;username2&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&#39;5678&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&#39;username3&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&#39;9012&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;raw_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&#39;Enter username: &#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;n&quot;&gt;ask&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;raw_input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&#39;Enter pin: &#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ask&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;database&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]:&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&#39;Welcome&#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&#39;Invalid code&#39;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt;you can try it&#39;s&lt;br /&gt;Neoriz&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/1955650928530192003/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2009/11/simple-login-with-dictionary-python.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/1955650928530192003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/1955650928530192003'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2009/11/simple-login-with-dictionary-python.html' title='A simple Login with Dictionary (Python)'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-8057554925632059697</id><published>2009-10-23T22:23:00.000-07:00</published><updated>2009-10-23T22:35:40.334-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><title type='text'>Create Form C# for Newbie</title><content type='html'>C# is the best, used very simple develop. You can try start with word &quot;Hello World&quot;.&lt;br /&gt;For Example :&lt;br /&gt;first, you create project, in project display mainform. You create this form with &lt;span style=&quot;font-style:italic;&quot;&gt;Hello World C# Newbie&lt;/span&gt; with label in properties.&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGoKvTcPGINPeNV6Ob5H9hHd5yT2mZrZlgGj43hg3A7qEskX8FtkB0VJP_I8t0QBiN8N6gvlHZB4psqx_MBJZt87AoNb9nVB_Bkj5iyuJ24XMSK0d1YNaQwcpjgn46fOnL_H11WiecC4I/s1600-h/fr_1.JPG&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 304px; height: 302px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGoKvTcPGINPeNV6Ob5H9hHd5yT2mZrZlgGj43hg3A7qEskX8FtkB0VJP_I8t0QBiN8N6gvlHZB4psqx_MBJZt87AoNb9nVB_Bkj5iyuJ24XMSK0d1YNaQwcpjgn46fOnL_H11WiecC4I/s320/fr_1.JPG&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5396034646481115250&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;second, you create subform&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrJvGMdx5D3l8JGuY6lp5JMDsUR_I5aXp9NNSky0LZN4Ic-LL7cw_tPLznPbnZkJvtXhSSoEPEYIPx-b0GaPKsguCoG0n-s6iUjVLE3MXLQ8uFWtbmDErGnQ-SCTrSMy0jNel0I4JJ0t4/s1600-h/fr_2.JPG&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 310px; height: 320px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrJvGMdx5D3l8JGuY6lp5JMDsUR_I5aXp9NNSky0LZN4Ic-LL7cw_tPLznPbnZkJvtXhSSoEPEYIPx-b0GaPKsguCoG0n-s6iUjVLE3MXLQ8uFWtbmDErGnQ-SCTrSMy0jNel0I4JJ0t4/s320/fr_2.JPG&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5396034875686003474&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;good luck&lt;br /&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/8057554925632059697/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2009/10/create-form-c-for-newbie.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/8057554925632059697'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/8057554925632059697'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2009/10/create-form-c-for-newbie.html' title='Create Form C# for Newbie'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGoKvTcPGINPeNV6Ob5H9hHd5yT2mZrZlgGj43hg3A7qEskX8FtkB0VJP_I8t0QBiN8N6gvlHZB4psqx_MBJZt87AoNb9nVB_Bkj5iyuJ24XMSK0d1YNaQwcpjgn46fOnL_H11WiecC4I/s72-c/fr_1.JPG" height="72" width="72"/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-3960288284304423723</id><published>2009-07-06T20:56:00.000-07:00</published><updated>2009-07-06T21:31:33.897-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Connecting Database</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;Now Connecting database with sourceCode Java. You can connecting database use driver from database as pasckage in library on this Java. The Driver connection get from vendor database such as Oracle, mySql and SqlSever etc.&lt;br /&gt;&lt;/div&gt;you can code java such as :&lt;br /&gt;&lt;br /&gt;This file save with name &lt;b&gt;ConnectionDatabase.java&lt;/b&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;package myPackage;&lt;br /&gt;&lt;br /&gt;import java.io.*;&lt;br /&gt;import java.sql.*;&lt;br /&gt;&lt;br /&gt;interface InterfaceDatabase {&lt;br /&gt; public void connectDatabase(String username, String password,&lt;br /&gt;   String oracleSID);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class ConnectionDatabase implements InterfaceDatabase {&lt;br /&gt; private String url;&lt;br /&gt; public Connection conn;&lt;br /&gt; public PreparedStatement pstm;&lt;br /&gt;&lt;br /&gt; //Override from InterfaceDatabase&lt;br /&gt; public void connectDatabase(String username, String password,&lt;br /&gt;   String DatabaseSID) {&lt;br /&gt;  try {&lt;br /&gt;   DriverManager.registerDriver(new &lt;i&gt;&lt;b&gt;driverDatabase..&lt;/b&gt;&lt;/i&gt;);&lt;br /&gt;   url = &quot;&lt;i&gt;&lt;b&gt;String connection driver&lt;/b&gt;&lt;/i&gt;&quot;;&lt;br /&gt;   conn = DriverManager.getConnection(url, username, password);&lt;br /&gt;  } catch (SQLException ex) {&lt;br /&gt;   ex.printStackTrace();&lt;br /&gt;   if (conn != null) {&lt;br /&gt;    try {&lt;br /&gt;     conn.rollback();&lt;br /&gt;    } catch (SQLException el) {&lt;br /&gt;     el.printStackTrace();&lt;br /&gt;    }&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public void disconnect() {&lt;br /&gt;  try {&lt;br /&gt;   pstm.close();&lt;br /&gt;   conn.close();&lt;br /&gt;  } catch (Exception e) {&lt;br /&gt;   e.printStackTrace();&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public void setQuery(String vsql) throws SQLException {&lt;br /&gt;  pstm = conn.prepareStatement(vsql);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;call on file with file &lt;b&gt;ConnUser.java&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;package myPackage;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import java.io.*;&lt;br /&gt;import java.sql.*;&lt;br /&gt;&lt;br /&gt;public class ConnUser {&lt;br /&gt; &lt;br /&gt; public static void connUser(ConnectionDatabase cd,String vsql)throws Exception{&lt;br /&gt;  cd.connectDatabase(&quot;username&quot;, &quot;password&quot;, &quot;database&quot;);  &lt;br /&gt;  cd.setQuery(vsql);&lt;br /&gt;  ResultSet rs=cd.pstm.executeQuery();&lt;br /&gt;  while(rs.next()){&lt;br /&gt;   System.out.println(rs.getInt(&lt;b&gt;index&lt;/b&gt;)+&quot; - &quot;+rs.getString(&lt;b&gt;index&lt;/b&gt;));&lt;br /&gt;  }&lt;br /&gt;  cd.disconnect();&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; public static void main (String[]args) throws Exception{&lt;br /&gt;  ConnectionDatabase db=new ConnectionDatabase();&lt;br /&gt;  connUser(db,&quot;&lt;i&gt;&lt;b&gt;Query Database&lt;/b&gt;&lt;/i&gt;&quot;);&lt;br /&gt;  &lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;good luck to try it&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/3960288284304423723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2009/07/connecting-database.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/3960288284304423723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/3960288284304423723'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2009/07/connecting-database.html' title='Connecting Database'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-6345001269366206451</id><published>2009-06-19T02:59:00.000-07:00</published><updated>2009-06-19T03:18:33.427-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="Tip and Triks"/><title type='text'>Loading and Saving Image with the Image I/O Library</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-size:180%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Introduced in J2SE 1.4&lt;/span&gt;&lt;/span&gt;, the javax.imageio package is the primary package for the Java Image I/O API. As its name implies, this package helps you read and write image files. You might wonder what&#39;s so important about this package. The fact is that you could read images with the getImage method of various classes like Toolkit and Applet since the initial release of the Java platform. But there is more to the javax.imageio package than simply reading images. One important point is that there was no writeImage or putImage previous to the Image I/O library. Now there is a way to write images. Also, you can now set properties such as compression level when you save images.&lt;br /&gt;&lt;br /&gt;The first question many people ask when working with the Image I/O libraries is what formats are supported? With Sun&#39;s reference implementation, you get a specific set. However, the API is flexible enough so that you can install your own formats by extending the necessary classes in the javax.imageio.spi library. For the moment, let&#39;s put that aspect of the library aside. To discover the installed set of readers and writers, you simply ask the ImageIO class through its getReaderFormatNames() and getWriterFormatNames() methods (or getReaderMIMETypes() and getWriterMIMETypes() if you want to work directly with MIME types). Here&#39;s an example:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;// show image and saving image with difference extension file or name file&lt;br /&gt;import java.awt.image.*;&lt;br /&gt;import javax.imageio.*;&lt;br /&gt;import java.io.*;&lt;br /&gt;import java.awt.*;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;public class Demo {&lt;br /&gt;private static class FrameShower implements Runnable {&lt;br /&gt;final Frame frame;&lt;br /&gt;&lt;br /&gt;public FrameShower(Frame frame) {&lt;br /&gt;this.frame = frame;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void run() {&lt;br /&gt;frame.show();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static void main(String args[]) throws IOException {&lt;br /&gt;&lt;br /&gt;// Read&lt;br /&gt;//File file = new File(args[0]);&lt;br /&gt;File file = new File(&quot;e:/campuran/ada/nyoba.jpg&quot;); //path file&lt;br /&gt;BufferedImage input = ImageIO.read(file);&lt;br /&gt;File outputFile = new File(&quot;e:/campuran/ada/image.png&quot;); //path file&lt;br /&gt;ImageIO.write(input, &quot;PNG&quot;, outputFile);&lt;br /&gt;// Convert ukuran&lt;br /&gt;Kernel sharpKernel = new Kernel(3, 3, new float[] { 0.0f, -1.0f, 0.0f,&lt;br /&gt;-1.0f, 5.0f, -1.0f, 0.0f, -1.0f, 0.0f });&lt;br /&gt;ConvolveOp convolveOp = new ConvolveOp(sharpKernel,&lt;br /&gt;ConvolveOp.EDGE_NO_OP, null);&lt;br /&gt;int width = input.getWidth();&lt;br /&gt;int height = input.getHeight();&lt;br /&gt;BufferedImage output = new BufferedImage(width, height,&lt;br /&gt;BufferedImage.TYPE_INT_ARGB);&lt;br /&gt;convolveOp.filter(input, output);&lt;br /&gt;// membuat tampilan&lt;br /&gt;Icon icon = new ImageIcon(output);&lt;br /&gt;JLabel label = new JLabel(icon);&lt;br /&gt;JFrame frame = new JFrame(&quot;Gambare&quot;);&lt;br /&gt;frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;frame.getContentPane().add(label, BorderLayout.CENTER);&lt;br /&gt;frame.pack();&lt;br /&gt;// show image&lt;br /&gt;Runnable runner = new FrameShower(frame);&lt;br /&gt;EventQueue.invokeLater(runner);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;You can check list from IO library javax.imageio.spi with :&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style=&quot;;font-family:arial;font-size:100%;&quot;  &gt;&lt;br /&gt;import javax.imageio.*;&lt;br /&gt;&lt;br /&gt;     public class GetList {&lt;br /&gt;       public static void main(String args[]) {&lt;br /&gt;         String readerNames[] = &lt;br /&gt;           ImageIO.getReaderFormatNames();&lt;br /&gt;         printlist(readerNames, &quot;Reader names:&quot;);&lt;br /&gt;         String readerMimes[] = &lt;br /&gt;           ImageIO.getReaderMIMETypes();&lt;br /&gt;         printlist(readerMimes, &quot;Reader MIME types:&quot;);&lt;br /&gt;         String writerNames[] = &lt;br /&gt;           ImageIO.getWriterFormatNames();&lt;br /&gt;         printlist(writerNames, &quot;Writer names:&quot;);&lt;br /&gt;         String writerMimes[] = &lt;br /&gt;           ImageIO.getWriterMIMETypes();&lt;br /&gt;         printlist(writerMimes, &quot;Writer MIME types:&quot;);&lt;br /&gt;       }&lt;br /&gt;       private static void printlist(String names[], &lt;br /&gt;                                        String title) {&lt;br /&gt;         System.out.println(title);&lt;br /&gt;         for (int i=0, n=names.length; i &lt; n; i++) {&lt;br /&gt;           System.out.println(&quot;\t&quot; + names[i]);&lt;br /&gt;         }&lt;br /&gt;       }&lt;br /&gt;     }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;good luck to try&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/6345001269366206451/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2009/06/loading-and-saving-image-with-image-io.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/6345001269366206451'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/6345001269366206451'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2009/06/loading-and-saving-image-with-image-io.html' title='Loading and Saving Image with the Image I/O Library'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-2361635968750031543</id><published>2009-05-13T21:39:00.001-07:00</published><updated>2009-05-13T23:42:43.724-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Using Connection cx_Oracle to Oracle in Python</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;For Connection python to Oracle use cx_Oracle. cx Oracle is a Python extension module thats allows access to Oracle Databases and conforms to the Python Database API specification. This module is currently built against Oracle 9.2.0, 10.2.0 and 11.1.0.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The interface specification consists of several sections:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Module Interface&lt;/li&gt;&lt;li&gt;Connection Objects&lt;/li&gt;&lt;li&gt;Cursor Object&lt;/li&gt;&lt;li&gt;Type Object and Constructors&lt;/li&gt;&lt;li&gt;Implementattion Hints for Module Authors&lt;/li&gt;&lt;li&gt;Optional DB API Extensions&lt;/li&gt;&lt;li&gt;Optional Error Handling Extensions&lt;/li&gt;&lt;li&gt;Optional Two-Phase Commit Extensions&lt;/li&gt;&lt;li&gt;Frequently Asked Questions&lt;/li&gt;&lt;li&gt;Major Changes from version 1.0 to Version 2.0&lt;/li&gt;&lt;li&gt;Open Issues&lt;/li&gt;&lt;li&gt;Footnotes&lt;/li&gt;&lt;li&gt;Unknowledgements&lt;/li&gt;&lt;/ul&gt;This information can look &lt;a href=&quot;http://www.python.org/dev/peps/pep-0249/&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;for Excample use cx_Oracle :&lt;br /&gt;&lt;blockquote&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;import sys, cx_Oracle&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;connect=cx_Oracle.Connection(&quot;system/password@Server_database&quot;)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;cursor=connect.cursor()&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;cursor.execute(&quot;PL/SQL or Query language&quot;)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;data=cursor.fetchall()&lt;/span&gt;&lt;br /&gt;data in method list, but can for print such as looping&lt;br /&gt;&lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;for (list fields) in data:&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;       print list fields&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;good luck,.......</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/2361635968750031543/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2009/05/using-connection-cxoracle-to-oracle-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/2361635968750031543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/2361635968750031543'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2009/05/using-connection-cxoracle-to-oracle-in.html' title='Using Connection cx_Oracle to Oracle in Python'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-159364773623307002.post-1891269516989963298</id><published>2009-03-02T18:08:00.000-08:00</published><updated>2009-05-14T00:24:11.991-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="example"/><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Python is powerful, simple and fast</title><content type='html'>&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXMVnvHFNYh7GGzU20TA4jTG3XxlreFI7eGGPDqF0oyI3VUNJ00riiqHztXciNTJDNe41RAKVI-HwFCDzVz42MNKp90fY9hOKP-pDMni1WMNT86XoE-HhJMiA3PvhaVGPj4SSsnGtr1s8/s1600-h/python_hello.JPG&quot;&gt;&lt;/a&gt;&lt;br /&gt;You can exercise python,...&lt;br /&gt;first you can text mode in window/Python Interactive Shell or PythonW in Edior, you write :&lt;br /&gt;&lt;blockquote&gt;print &quot;Hello word Neoriz&quot;&lt;br /&gt;result &gt;&gt; Hello word Neoriz&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXMVnvHFNYh7GGzU20TA4jTG3XxlreFI7eGGPDqF0oyI3VUNJ00riiqHztXciNTJDNe41RAKVI-HwFCDzVz42MNKp90fY9hOKP-pDMni1WMNT86XoE-HhJMiA3PvhaVGPj4SSsnGtr1s8/s1600-h/python_hello.JPG&quot;&gt;&lt;img style=&quot;margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 386px; height: 158px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXMVnvHFNYh7GGzU20TA4jTG3XxlreFI7eGGPDqF0oyI3VUNJ00riiqHztXciNTJDNe41RAKVI-HwFCDzVz42MNKp90fY9hOKP-pDMni1WMNT86XoE-HhJMiA3PvhaVGPj4SSsnGtr1s8/s320/python_hello.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5308782613954095682&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/blockquote&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXMVnvHFNYh7GGzU20TA4jTG3XxlreFI7eGGPDqF0oyI3VUNJ00riiqHztXciNTJDNe41RAKVI-HwFCDzVz42MNKp90fY9hOKP-pDMni1WMNT86XoE-HhJMiA3PvhaVGPj4SSsnGtr1s8/s1600-h/python_hello.JPG&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Using the Python Interpreter&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Invoking the Interpreter&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Python interpreter is usually installed as /usr/local/bin/python on those machines where it is available; putting /usr/local/bin in your Unix shell&#39;s search path makes it possible to start it by typing the command&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;python&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;to the shell. Since the choice of the directory where the interpreter lives is an installation option, other places are possible; check with your local Python guru or system administrator. (E.g., /usr/local/python is a popular alternative location.)&lt;br /&gt;&lt;br /&gt;On Windows machines, the Python installation is usually placed in C:\Python25, though you can change this when you&#39;re running the installer. To add this directory to your path, you can type the following command into the command prompt in a DOS box:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;set path=%path%;C:\python25&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Typing an end-of-file character (Control-D on Unix, Control-Z on Windows) at the primary prompt causes the interpreter to exit with a zero exit status. If that doesn&#39;t work, you can exit the interpreter by typing the following commands: &quot;import sys; sys.exit()&quot;.&lt;br /&gt;&lt;br /&gt;The interpreter&#39;s line-editing features usually aren&#39;t very sophisticated. On Unix, whoever installed the interpreter may have enabled support for the GNU readline library, which adds more elaborate interactive editing and history features. Perhaps the quickest check to see whether command line editing is supported is typing Control-P to the first Python prompt you get. If it beeps, you have command line editing; see Appendix A for an introduction to the keys. If nothing appears to happen, or if P is echoed, command line editing isn&#39;t available; you&#39;ll only be able to use backspace to remove characters from the current line.&lt;br /&gt;&lt;br /&gt;The interpreter operates somewhat like the Unix shell: when called with standard input connected to a tty device, it reads and executes commands interactively; when called with a file name argument or with a file as standard input, it reads and executes a script from that file.&lt;br /&gt;&lt;br /&gt;A second way of starting the interpreter is &quot;python -c command [arg] ...&quot;, which executes the statement(s) in command, analogous to the shell&#39;s -c option. Since Python statements often contain spaces or other characters that are special to the shell, it is best to quote command in its entirety with double quotes.&lt;br /&gt;&lt;br /&gt;Some Python modules are also useful as scripts. These can be invoked using &quot;python -m module [arg] ...&quot;, which executes the source file for module as if you had spelled out its full name on the command line.&lt;br /&gt;&lt;br /&gt;Note that there is a difference between &quot;python file&quot; and &quot;python &quot;. In the latter case, input requests from the program, such as calls to input() and raw_input(), are satisfied from file. Since this file has already been read until the end by the parser before the program starts executing, the program will encounter end-of-file immediately. In the former case (which is usually what you want) they are satisfied from whatever file or device is connected to standard input of the Python interpreter.&lt;br /&gt;&lt;br /&gt;When a script file is used, it is sometimes useful to be able to run the script and enter interactive mode afterwards. This can be done by passing -i before the script. (This does not work if the script is read from standard input, for the same reason as explained in the previous paragraph.)&lt;br /&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Argument Passing&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When known to the interpreter, the script name and additional arguments thereafter are passed to the script in the variable sys.argv, which is a list of strings. Its length is at least one; when no script and no arguments are given, sys.argv[0] is an empty string. When the script name is given as &#39;-&#39; (meaning standard input), sys.argv[0] is set to &#39;-&#39;. When -c command is used, sys.argv[0] is set to &#39;-c&#39;. When -m module is used, sys.argv[0] is set to the full name of the located module. Options found after -c command or -m module are not consumed by the Python interpreter&#39;s option processing but left in sys.argv for the command or module to handle.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Interactive Mode&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When commands are read from a tty, the interpreter is said to be in interactive mode. In this mode it prompts for the next command with the primary prompt, usually three greater-than signs (&quot;&gt;&gt;&gt; &quot;); for continuation lines it prompts with the secondary prompt, by default three dots (&quot;... &quot;). The interpreter prints a welcome message stating its version number and a copyright notice before printing the first prompt:&lt;br /&gt;&lt;br /&gt;python Python 1.5.2b2 (#1, Feb 28 1999, 00:02:06)  [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam &gt;&gt;&gt;&lt;br /&gt;&lt;br /&gt;Continuation lines are needed when entering a multi-line construct. As an example, take a look at this if statement:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&gt;&gt;&gt; the_world_is_flat = 1&lt;br /&gt;&gt;&gt;&gt; if the_world_is_flat:&lt;br /&gt;       ...     print &quot;Be careful not to fall off!&quot; ...  Be careful not to fall off!&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;The Interpreter and Its Environment&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Error Handling&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When an error occurs, the interpreter prints an error message and a stack trace. In interactive mode, it then returns to the primary prompt; when input came from a file, it exits with a nonzero exit status after printing the stack trace. (Exceptions handled by an except clause in a try statement are not errors in this context.) Some errors are unconditionally fatal and cause an exit with a nonzero exit; this applies to internal inconsistencies and some cases of running out of memory. All error messages are written to the standard error stream; normal output from executed commands is written to standard output.&lt;br /&gt;&lt;br /&gt;Typing the interrupt character (usually Control-C or DEL) to the primary or secondary prompt cancels the input and returns to the primary prompt.2.1Typing an interrupt while a command is executing raises the KeyboardInterrupt exception, which may be handled by a try statement.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Executable Python Scripts&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;On BSD&#39;ish Unix systems, Python scripts can be made directly executable, like shell scripts, by putting the line&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;#! /usr/bin/env python&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(assuming that the interpreter is on the user&#39;s PATH) at the beginning of the script and giving the file an executable mode. The &quot;#!&quot; must be the first two characters of the file. On some platforms, this first line must end with a Unix-style line ending (&quot;\n&quot;), not a Mac OS (&quot;\r&quot;) or Windows (&quot;\r\n&quot;) line ending. Note that the hash, or pound, character, &quot;#&quot;, is used to start a comment in Python.&lt;br /&gt;&lt;br /&gt;The script can be given an executable mode, or permission, using the chmod command:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;$ chmod +x myscript.py&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Source Code Encoding&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It is possible to use encodings different than ASCII in Python source files. The best way to do it is to put one more special comment line right after the #! line to define the source file encoding:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;  # -*- coding: encoding -*-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;With that declaration, all characters in the source file will be treated as having the encoding encoding, and it will be possible to directly write Unicode string literals in the selected encoding. The list of possible encodings can be found in the Python Library Reference, in the section on codecs.&lt;br /&gt;&lt;br /&gt;For example, to write Unicode literals including the Euro currency symbol, the ISO-8859-15 encoding can be used, with the Euro symbol having the ordinal value 164. This script will print the value 8364 (the Unicode codepoint corresponding to the Euro symbol) and then exit:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;# -*- coding: iso-8859-15 -*-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;currency = u&quot;€&quot;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;print ord(currency)&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;If your editor supports saving files as UTF-8 with a UTF-8 byte order mark (aka BOM), you can use that instead of an encoding declaration. IDLE supports this capability if Options/General/Default Source Encoding/UTF-8 is set. Notice that this signature is not understood in older Python releases (2.2 and earlier), and also not understood by the operating system for script files with #! lines (only used on Unix systems).&lt;br /&gt;&lt;br /&gt;By using UTF-8 (either through the signature or an encoding declaration), characters of most languages in the world can be used simultaneously in string literals and comments. Using non-ASCII characters in identifiers is not supported. To display all these characters properly, your editor must recognize that the file is UTF-8, and it must use a font that supports all the characters in the file.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;The Interactive Startup File&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When you use Python interactively, it is frequently handy to have some standard commands executed every time the interpreter is started. You can do this by setting an environment variable named PYTHONSTARTUP to the name of a file containing your start-up commands. This is similar to the .profile feature of the Unix shells.&lt;br /&gt;&lt;br /&gt;This file is only read in interactive sessions, not when Python reads commands from a script, and not when /dev/tty is given as the explicit source of commands (which otherwise behaves like an interactive session). It is executed in the same namespace where interactive commands are executed, so that objects that it defines or imports can be used without qualification in the interactive session. You can also change the prompts sys.ps1 and sys.ps2 in this file.&lt;br /&gt;&lt;br /&gt;If you want to read an additional start-up file from the current directory, you can program this in the global start-up file using code like &quot;if os.path.isfile(&#39;.pythonrc.py&#39;): execfile(&#39;.pythonrc.py&#39;)&quot;. If you want to use the startup file in a script, you must do this explicitly in the script:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;import os&lt;br /&gt;filename = os.environ.get(&#39;PYTHONSTARTUP&#39;)&lt;br /&gt;if filename and os.path.isfile(filename):   &lt;br /&gt;              execfile(filename)&lt;/blockquote&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://neoriz2.blogspot.com/feeds/1891269516989963298/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neoriz2.blogspot.com/2009/03/python-is-powerful-simple-and-fast.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/1891269516989963298'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/159364773623307002/posts/default/1891269516989963298'/><link rel='alternate' type='text/html' href='http://neoriz2.blogspot.com/2009/03/python-is-powerful-simple-and-fast.html' title='Python is powerful, simple and fast'/><author><name>neoriz</name><uri>http://www.blogger.com/profile/05021003549458990897</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAZB5PDCOsKYga0q1HTjxZuwRmZ6iG2RFsGGBEjmmmtMHPuVXmmHGeRfJhE5_oC_h9h8jXr5HVmIJE_ZuK1-GSAHMNWBbazyjRW134JvUJUXhkA2q0HClLsns8q9jcMvw/s220/pororo-2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXMVnvHFNYh7GGzU20TA4jTG3XxlreFI7eGGPDqF0oyI3VUNJ00riiqHztXciNTJDNe41RAKVI-HwFCDzVz42MNKp90fY9hOKP-pDMni1WMNT86XoE-HhJMiA3PvhaVGPj4SSsnGtr1s8/s72-c/python_hello.JPG" height="72" width="72"/><thr:total>1</thr:total></entry></feed>