How does Python call the system/primitive calls ?

2005-04-11 Thread James Yu
d readings ?-- James Yu[EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Need help to figure out urllib2.Request()

2008-02-18 Thread James Yu
Hi folks, I tried to open some web pages with urllib2.Request(url, data, headers), but it always give me a 404 error. Eg. url = 'http://www.whatever.com/somephp.php' data = {} data['id'] = account for i in book2Open: data['book'] = i url_data = urllib.urlencode(data) request = urllib2.

How to overcome the incomplete download with urllib.urlretrieve ?

2008-02-18 Thread James Yu
This is part of my code that invokes urllib.urlretrieve: > for i in link2Visit: > localName = i.split('/') > i = i.replace(' ', '%20') > tgtPath = ['d:\\', 'work', 'python', 'grab_n_view'] > localPath = '' > for j in tgtPath: > localPath = os.path.join(localPath, j) >

how to write text into file in ansi encoding ?

2008-02-20 Thread James Yu
I am using *fileHandle = open(srcFile, 'w')* + *fileHandle.write('whatever') * to put text into a file, and Python uses utf-8 encoding by default. How do I configure or do anything to make Python writing files in ansi encoding ? -- This is a UTF-8 formatted mail --

Re: how to write text into file in ansi encoding ?

2008-02-20 Thread James Yu
I just figure out the how-to: # first we open and read in chars as in utf-8 encoding ansiLine = line.decode('utf-8', 'ignore') # then writing it into another file in any encoding you like, it's big5 in my case. src_handle.write(ansiLine.encode('big5', 'ignore')) -- This is a UTF-8 formatted mail

The stange behaviour of Tkinter.Canvas

2008-03-11 Thread James Yu
I tried to update the rectangle on a canvas to get the visual effect of progressbar. It works all right if I delete the existing objects (rectangle and text) and create a new one. However, if I invoke canvas.itemconfig() to update the existing objects' options, gui just went nuts. I am more than ha

How to import custom python file in python server page (psp) ?

2008-03-14 Thread James Yu
Hi folks, I prepared a python script for dynamically get the absolute paths of the files in certain folder. Then I tried to invoke that function from my web server in a .psp file like this: 1 2 3 asdfasdfasdfa 4 5 <% 6 import glob 7 import os 8 *

click on hyper link and got 404 error

2008-04-14 Thread James Yu
I am using "mod_python.publisher" to generate my web page that contains serveral links to local files. I also replace the path with my domain name like this: curDir = os.path.dirname(__file__) link = 'http://' + hostname + '/' + os.path.basename(curDir) + '/' files = os.listdir(curDir) for i in fi