<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title> &#187; python</title>
	<atom:link href="http://chonlatee.wordpress.com/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://chonlatee.wordpress.com</link>
	<description></description>
	<lastBuildDate>Mon, 17 Mar 2008 09:35:50 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='chonlatee.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/11af6f7bd5722e30d01a13939626c3eb?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title> &#187; python</title>
		<link>http://chonlatee.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://chonlatee.wordpress.com/osd.xml" title="" />
		<item>
		<title>เคย refactor code ที่เขียนมั้ย</title>
		<link>http://chonlatee.wordpress.com/2008/03/17/%e0%b9%80%e0%b8%84%e0%b8%a2-refactor-code-%e0%b8%97%e0%b8%b5%e0%b9%88%e0%b9%80%e0%b8%82%e0%b8%b5%e0%b8%a2%e0%b8%99%e0%b8%a1%e0%b8%b1%e0%b9%89%e0%b8%a2/</link>
		<comments>http://chonlatee.wordpress.com/2008/03/17/%e0%b9%80%e0%b8%84%e0%b8%a2-refactor-code-%e0%b8%97%e0%b8%b5%e0%b9%88%e0%b9%80%e0%b8%82%e0%b8%b5%e0%b8%a2%e0%b8%99%e0%b8%a1%e0%b8%b1%e0%b9%89%e0%b8%a2/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 09:35:50 +0000</pubDate>
		<dc:creator>chonlatee</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://chonlatee.wordpress.com/?p=17</guid>
		<description><![CDATA[    หัวข้อที่แล้วแนะนำ แหม่จะพูดแนะนำก็ไม่ถูกเพราะไอ้ที่ผมเขียนก็มีอาจารย์ท่านหนึ่งบอกมาอีกที แต่ก็นั้นแหละ ขอพูดว่าแนะนำละกัน  ได้คุยกับเขาแหละเขาก็แนะนำการ refactor code ผมก็งงว่ามันคืออะไร อาจารย์ท่านนั้นก็บอกว่า มันคือการทำให้ code ของเราอ่านเข้าใจง่ายขึ้น ดูไม่ซับซ้อน เวลาใครนำไปใช้หรือ นำไปพัฒนาต่อเขาได้ดูง่ายๆ ผมก็บอกว่าไม่เคยได้ยิน อาจารย์ก็บอกอีกว่า คือคนไทยยังไม่ค่อยชินกับการ refactor code เท่าไร พอจะพัฒนาต่อก็ไม่ได้ ทำให้ต้องทำใหม่หมด ทำให้เสียเวลา  เพราะฉนั้นแล้วการ refactor code ถือว่าสำคัญ ผมเองยังไม่ค่อยเก่ง programming เท่าไรก็ได้อาจารย์ท่านนั้นสอน แล้วก็นำมาเขียน blog อีกทีนึง เอาละ การ refactor code เราจะทำยังไงกันดี
ตัดสิ่งที่ไม่จำเป็นออกไป ผมว่าตรงตัวนะ refactor   ยกตัวอย่างเช่น   คุณเขียน program บวกเลข ยกตัวอย่างเช่น เขียนง่ายๆก็จะได้ประมาณนี้ทำเป็น function นะ
def add(a,b):
c = a + b
return [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chonlatee.wordpress.com&blog=2423020&post=17&subd=chonlatee&ref=&feed=1" />]]></description>
		<wfw:commentRss>http://chonlatee.wordpress.com/2008/03/17/%e0%b9%80%e0%b8%84%e0%b8%a2-refactor-code-%e0%b8%97%e0%b8%b5%e0%b9%88%e0%b9%80%e0%b8%82%e0%b8%b5%e0%b8%a2%e0%b8%99%e0%b8%a1%e0%b8%b1%e0%b9%89%e0%b8%a2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4f7baa5f1917673d1bacb6fedbb88eab?s=96&#38;d=identicon" medium="image">
			<media:title type="html">chonlatee</media:title>
		</media:content>
	</item>
		<item>
		<title>code ที่คุณเขียนใช้เวลาเท่าไร</title>
		<link>http://chonlatee.wordpress.com/2008/03/13/code-%e0%b8%97%e0%b8%b5%e0%b9%88%e0%b8%84%e0%b8%b8%e0%b8%93%e0%b9%80%e0%b8%82%e0%b8%b5%e0%b8%a2%e0%b8%99%e0%b9%83%e0%b8%8a%e0%b9%89%e0%b9%80%e0%b8%a7%e0%b8%a5%e0%b8%b2%e0%b9%80%e0%b8%97%e0%b9%88/</link>
		<comments>http://chonlatee.wordpress.com/2008/03/13/code-%e0%b8%97%e0%b8%b5%e0%b9%88%e0%b8%84%e0%b8%b8%e0%b8%93%e0%b9%80%e0%b8%82%e0%b8%b5%e0%b8%a2%e0%b8%99%e0%b9%83%e0%b8%8a%e0%b9%89%e0%b9%80%e0%b8%a7%e0%b8%a5%e0%b8%b2%e0%b9%80%e0%b8%97%e0%b9%88/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 09:09:24 +0000</pubDate>
		<dc:creator>chonlatee</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://chonlatee.wordpress.com/?p=16</guid>
		<description><![CDATA[    ปัญหาอีกอย่างนึงของคนเขียนโปรแกรมคือ นอกจากจะได้ output ที่ออกมาตามความต้องการแล้ว คุณต้องทำให้ไว ถ้าทำได้ให้ล้านนึง(กำ เหมือนรายการไรหว่าจำไม่ได้)  เพราะว่าความเร็วถือว่าเป็นปัจจัยสำคัญในการเขียนโปรแกรมอีกอย่างหนึ่งเลยก็ว่าได้  ยิ่งคุณเขียน code ให้ทำงานไว ประมวลผลใช้เวลาไม่นาน ก็อาจจะทำให้ประสิทธิภาพโดยรวมดีขี้น เพราะเดี๋ยวนี้อะไรมันต้องไวครับ (เหมือนโฆษณาอะไรหว่า) คือบางทีการเขียน code นี้มันวัดกึ๋นคนเขียนเลยก็ว่าได้นะ แต่ผมเขียนไม่เก่งหรอก ผมอยากเป็น programmer เก่งๆ ตอนนี้ก็คลืบคลาน มืด 11 ด้านอยู่ ก็หัดไปเรื่อยๆ เดี๋ยวจะคิดว่าผมเป็นโปรแกรมเมอร์ เหอๆ (คงไม่มีใครคิดหรอกมั้งเพราะดูจาก code ที่เขียนไม่เซียนเลย) ร่ายสะยาวไปดูวิธีตรวจสอบโปรแกรมดีกว่าว่าเร็วขนาดไหน อันนี้ได้มาจากพี่ท่านหนึ่งครับ เขาเป็นอาจารย์ แล้วก็เขียนโปรแกรม ไม่ได้จบ คอมพิวเตอร์มา แต่เก่งเขียนโปรแกรมมาก เพราะฉนั้นแล้ว ผมว่า อยู่ที่ใจรักจริงๆ ต้องขอบคุณท่านนี้ครับที่ มอบความรู้ให้ผม มาดู code กันเลย
from datetime import datetime
start = datetime.now()
for i in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chonlatee.wordpress.com&blog=2423020&post=16&subd=chonlatee&ref=&feed=1" />]]></description>
		<wfw:commentRss>http://chonlatee.wordpress.com/2008/03/13/code-%e0%b8%97%e0%b8%b5%e0%b9%88%e0%b8%84%e0%b8%b8%e0%b8%93%e0%b9%80%e0%b8%82%e0%b8%b5%e0%b8%a2%e0%b8%99%e0%b9%83%e0%b8%8a%e0%b9%89%e0%b9%80%e0%b8%a7%e0%b8%a5%e0%b8%b2%e0%b9%80%e0%b8%97%e0%b9%88/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4f7baa5f1917673d1bacb6fedbb88eab?s=96&#38;d=identicon" medium="image">
			<media:title type="html">chonlatee</media:title>
		</media:content>
	</item>
		<item>
		<title>แยก string ด้วย split ใน python</title>
		<link>http://chonlatee.wordpress.com/2008/03/11/%e0%b9%81%e0%b8%a2%e0%b8%81-string-%e0%b8%94%e0%b9%89%e0%b8%a7%e0%b8%a2-split-%e0%b9%83%e0%b8%99-python/</link>
		<comments>http://chonlatee.wordpress.com/2008/03/11/%e0%b9%81%e0%b8%a2%e0%b8%81-string-%e0%b8%94%e0%b9%89%e0%b8%a7%e0%b8%a2-split-%e0%b9%83%e0%b8%99-python/#comments</comments>
		<pubDate>Tue, 11 Mar 2008 07:41:16 +0000</pubDate>
		<dc:creator>chonlatee</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://chonlatee.wordpress.com/?p=13</guid>
		<description><![CDATA[    python นั้นมี function แยก string ด้วย space  ถ้าเป็น default แต่ท่านก็สามารถให้ function นี้แยกด้วยอะไรก็ได้ ตามที่ท่านต้องการ เอามาดูกันว่าทำยังไง
สมมุติว่ามี string ประมาณนี้
string = &#8220;111111 222222 3333333&#8243;
สามารถสั่งได้ด้วยการ
string.split()
ก็จะได้
['111111','222222','3333333']
แต่ถ้าเกิดเราไม่เอาหมดหละเราจะเอาแค่ 111111 ทำยังไง หรือจะเอาแค่ 222222 หรือจะเป็น 3333333 จะทำยังไง เราก็สั่งมันยังงี้ครับ
s= string.split()    #แยก string
n = s[0]               [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chonlatee.wordpress.com&blog=2423020&post=13&subd=chonlatee&ref=&feed=1" />]]></description>
		<wfw:commentRss>http://chonlatee.wordpress.com/2008/03/11/%e0%b9%81%e0%b8%a2%e0%b8%81-string-%e0%b8%94%e0%b9%89%e0%b8%a7%e0%b8%a2-split-%e0%b9%83%e0%b8%99-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4f7baa5f1917673d1bacb6fedbb88eab?s=96&#38;d=identicon" medium="image">
			<media:title type="html">chonlatee</media:title>
		</media:content>
	</item>
		<item>
		<title>commandline argument</title>
		<link>http://chonlatee.wordpress.com/2008/03/08/commandline-argument/</link>
		<comments>http://chonlatee.wordpress.com/2008/03/08/commandline-argument/#comments</comments>
		<pubDate>Sat, 08 Mar 2008 12:16:02 +0000</pubDate>
		<dc:creator>chonlatee</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://chonlatee.wordpress.com/?p=10</guid>
		<description><![CDATA[    ครั้งที่แล้วผมเขียนเกี่ยวกับการเปิดไฟล์อ่าน แต่ว่าระบุไฟล์ลงไปว่าเปิดไฟล์อะไร แต่ถ้าเราไม่ระบุหละว่าไฟล์อะไร เราอยากให้มันทำได้ทุกไฟล์ ก็ต้องใช้ทำแบบ commandline argument ตอนแรกผมก็ไม่รู้จะทำยังไง ก็หาจาก internet อีกนั้นแหละ ก็ search หาเอา ก็ไปเจอตัว sys.argv พอดูๆก็มาดัดแปลงเอาก็ได้
import sys
for i in open(sys.argv[1]):
if i.startswith(&#8220;&#62;&#8221;):
print i,

อันนี้คือเราจะทำได้ทุกไฟล์ก็คือให้แสดงบรรทัดที่ขึ้นต้นด้วย &#62; ในไฟล์ที่เราต้องการ เวลา compile ก็
python file.py   openfile.*
โดยที่ file.py คือ file ที่เรา save code ไว้ และ openfile.* คือไฟล์ที่เราจะเปิด  แค่นี้ก็ได้แล้วเห็นมั้ยครับว่าง่ายๆ
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chonlatee.wordpress.com&blog=2423020&post=10&subd=chonlatee&ref=&feed=1" />]]></description>
		<wfw:commentRss>http://chonlatee.wordpress.com/2008/03/08/commandline-argument/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4f7baa5f1917673d1bacb6fedbb88eab?s=96&#38;d=identicon" medium="image">
			<media:title type="html">chonlatee</media:title>
		</media:content>
	</item>
		<item>
		<title>เปิดอ่าน file ด้วย python</title>
		<link>http://chonlatee.wordpress.com/2008/03/08/%e0%b9%80%e0%b8%9b%e0%b8%b4%e0%b8%94%e0%b8%ad%e0%b9%88%e0%b8%b2%e0%b8%99-file-%e0%b8%94%e0%b9%89%e0%b8%a7%e0%b8%a2-python/</link>
		<comments>http://chonlatee.wordpress.com/2008/03/08/%e0%b9%80%e0%b8%9b%e0%b8%b4%e0%b8%94%e0%b8%ad%e0%b9%88%e0%b8%b2%e0%b8%99-file-%e0%b8%94%e0%b9%89%e0%b8%a7%e0%b8%a2-python/#comments</comments>
		<pubDate>Sat, 08 Mar 2008 10:07:03 +0000</pubDate>
		<dc:creator>chonlatee</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://chonlatee.wordpress.com/?p=8</guid>
		<description><![CDATA[    อันที่จริงแล้วผมก็เพิ่งศึกษา python แหละแต่พอดีได้โจทย์มา พอได้มาก็ลองค้นหาดูว่ามันทำยังไงก็เจอ โจทย์ก็คือ
เปิดไฟล์ แต่ผมยังศึกษาไม่ถึง file i/o เลย ก็เปิด file แล้วเอาบรรทัดที่มี &#62;  นำหน้า  ผมก็หาใน internet นั่งทำอยู่วันกว่าก็ได้
import sys
for i in open(&#8220;ชื่อไฟล์&#8221;):
if &#8220;&#62;&#8221; in i:
print i,

แต่มันก็ติดตรงว่า ถ้ามันมีตัว &#62; อยู่ตรงกลางมันก็ปริ้น มีพี่คนนึงแนะนำมาว่าลองไปดู function ที่ชื่อว่า startswith ก็เลยได้ ตรงตามต้องการเลยคือ  print เฉพาะบรรทัดที่ &#62; นำหน้า
import sys
for  i in open(&#8220;ชื่อไฟล์&#8221;):
if i.startswith(&#8220;&#62;&#8221;):
print i,

ทีนี้มันก็จะ print เฉพาะบรรทัดที่ &#62; นำหน้า เห็นมั้ยละครับว่า python ง่ายๆ
    [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chonlatee.wordpress.com&blog=2423020&post=8&subd=chonlatee&ref=&feed=1" />]]></description>
		<wfw:commentRss>http://chonlatee.wordpress.com/2008/03/08/%e0%b9%80%e0%b8%9b%e0%b8%b4%e0%b8%94%e0%b8%ad%e0%b9%88%e0%b8%b2%e0%b8%99-file-%e0%b8%94%e0%b9%89%e0%b8%a7%e0%b8%a2-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4f7baa5f1917673d1bacb6fedbb88eab?s=96&#38;d=identicon" medium="image">
			<media:title type="html">chonlatee</media:title>
		</media:content>
	</item>
	</channel>
</rss>