Python

warning: Creating default object from empty value in /home/www/virtual/phaisarn.com/sun/htdocs/modules/taxonomy/taxonomy.pages.inc on line 33.

Devhelp

Devhelp คือเครื่องมือช่วยค้นหา Document ใน Ubuntu สามารถทำการติดตั้งได้ดังนี้
sudo apt-get install devhelp
เวลาใช้งานก็เข้าไปที่
Applications → Programming  → Devhelp
ที่มา: Programming

Python เรียกใช้ Command line

การเรียกใช้ command line จาก Python สามารถเรียกได้โดยใช้คำสั่ง popen
    import os
    ipFile = "ip.txt"
    opFile = "op.txt"
    cmd = 'swath <%s> %s' % (ipFile, opFile)
    f = os.popen(cmd)

หรือใช้ Popen

การติดตั้ง Pydev

เปิด Eclipse ขึ้นมา จากนั้นไปที่เมนู Help > Install New Software

แล้วทำการ Add Site ดังภาพด้านล่างนี้

 

ใช้งาน External command ด้วย Python

import os
os.system("dir c:")

อ่าน-เขียนไฟล์ด้วย Python

เชียนไฟล์
f = open('/tmp/workfile', 'w')
อ่านไฟล์
f.read()
อ่านไฟล์เป็นบรรทัด
f.readline()

ตัวอย่างการใช้ pickle
http://docs.python.org/library/pickle.html

 
ที่มา: daimi.au.dk/~besen/TBiB2007/lecture-notes/persistence.html, docs.python.org/tutorial/inputoutput.html
 
 

Creating Drupal content using Python

เท่าที่ลองยังใช้ไม่ได้

แต่ไว้ดูเป็น Guildline น่ะ

http://qandr.org/quentin/writings/drupy

ตัวอย่าง code การใช้ Python ติดต่อ XML-RPC ของ Drupal

 #!/usr/bin/env python

import xmlrpclib
server = xmlrpclib.Server("http://localhost/drupal/xmlrpc.php")

for method in server.system.listMethods():
        print method
        print server.system.methodHelp(method)
        print
 

ติดตั้ง Epydoc บน Windows XP

ดาวน์โหลด และติดตั้ง Epydoc

ดาวน์โหลด Epydoc จาก http://sourceforge.net/projects/epydoc/files/
จะได้ไฟล์ epydoc-3.0.1.win32.exe
ให้ทำการ Double click เพื่อทำการติดตั้ง
หลังจากติดตั้ง Epydoc แล้วจะได้ไฟล์มา 2ไฟล์ ให้ใชงานอยู่ในโฟลเดอร์ C:\Python25\Scripts

  1. epydoc.pyw มี GUI ให้ใช้
  2. epydoc.py สำหรับการใช้งานแบบ command line

การใช้งาน Epydoc

http://epydoc.sourceforge.net/using.html

Syndicate content