Python
Printing XML in Python
Once you have read an XML document or generated a new one, you might want to write them to a file, standard output, or even a string. Python provides many options to print out XML in string. Let me start from the very basic one.
print doc.toxml()
Easy! Now I will go to more advanced version of printing XML. Python offers good extension APIs and we should try them. First of all, don’t forget to import them and it’s rocking!
import sys
sugree's blog
Add new comment
Read more
2002 reads
BTQueue migrated to Subversion
Actually, I managed to fix a freezing bug regarding failure during hash check for a week. Unfortunately, I can’t commit the patch to CVS at cvs.sourceforge.net because of connection refused error. It seems sourceforge is trying to force every projects to migrate to Subversion as soon as possible. They don’t want to maintain CVS anymore so CVS is now very unstable and nobody takes core of them for a week.
- sugree's blog
- Add new comment
- Read more
- 1577 reads
Parsing XML in Python
XML is a popular data format because of its flexibility and extensibility. It is widely used to describe hierarchical data. For any data format, you need at least 2 operations: read and write. Basically, XML data is in form of tree. Once you have the XML tree, you can generate XML by walking through all nodes in that tree. So the biggest problem is to read XML tree from text stream, text file or text string. This process is usually called as parsing.
- sugree's blog
- Add new comment
- Read more
- 2908 reads
Programmable FTP Client
FTP may not be as secure as SFTP but it is very fast. SFTP is best for personal usage. If you are sharing non-critical files among group of users, FTP seems to be better choice. Note that there is no shell access for those users. For example, a set of users are sharing a server space placed at a high-speed data center. Everyone placed requests to download new files everyday. In other words, all users download files to temporarily store in the server and then get them back home through FTP.
- sugree's blog
- Add new comment
- Read more
- 1655 reads
ฟังก์ชั่น
สำหรับการเขียนโปรแกรม ไม่ว่าโปรแกรมนั้นจะแปลกหรือซับซ้อนแค่ไหน สุดท้ายโปรแกรมทุกโปรแกรมก็ต้องใช้เพียงแค่ ตัวแปร และ คำสั่งควบคุม เพียงสองส่วนประกอบนี้ก็สามารถเขียนโปรแกรมใดๆ ก็ได้ อย่างไรก็ตามโปรแกรมที่ซับซ้อนไม่จะมีลักษณะพิเศษที่พ่วงท้ายมาด้วยเสมอ นั่นคือ โปรแกรมใดๆ จะมีส่วนที่ซ้ำกันเสมอ ถ้าส่วนที่ซ้ำกันต้องทำซ้ำๆ ติดๆ กันก็จะกลายเป็น ลูป แต่ถ้าไม่ได้ซ้ำติดๆ กัน ก็จะทำให้ไม่สามารถเขียนเป็น ลูป ได้ โปรแกรมส่วนนั้นก็จะซ้ำกันโดยปริยาย และแล้วก็ถึงบทพระเอกของ ฟังก์ชั่น
- Add new comment
- Read more
- 10379 reads
Comparison of ruby and python line by line (3/3)
This post is the last part of this comparison. I am going to demonstrate how to develop XML-RPC server and client in Ruby and Python. As I said earlier, I don’t know much about Ruby. Below ruby codes are based on an article in Linux Journal #144. I just tried to develop similar program in Python. There are 2 parts; server and client. Let me start from the server.
- sugree's blog
- Add new comment
- Read more
- 1879 reads
Recent comments
3 years 34 weeks ago
3 years 39 weeks ago
3 years 39 weeks ago
3 years 40 weeks ago
3 years 40 weeks ago
3 years 42 weeks ago
3 years 42 weeks ago
3 years 42 weeks ago
3 years 43 weeks ago
3 years 43 weeks ago