วันพฤหัสบดีที่ 23 กรกฎาคม พ.ศ. 2552

PLY (Python Lex and Yacc)

PLY เป็นเครื่องมือในการทำ Lex กับ Yacc โดยใช้ภาษาไพธอน

วันอาทิตย์ที่ 12 กรกฎาคม พ.ศ. 2552

Edit in place

inputfile.txt

goodbye
hello
see you later!


edit.py

import fileinput
for lines in fileinput.FileInput("inputfile.txt", inplace=1): ## edit file in place
lines = lines.replace("hello","hi")
print lines.replace('\n','') ## although this prints the line, the file will be modified.



inputfile.txt

goodbye
hi
see you later!


จาก ubuntuforums

วันพฤหัสบดีที่ 2 กรกฎาคม พ.ศ. 2552

Sphinx

Sphinx เป็นเครื่องมือที่ใช้ในการสร้างคู่มือให้กับ python