Reading output from a child process non-blockingly

2005-06-29 Thread Yuan HOng
In my program I have to call an external program and parse its output. For that I use the os.popen2 function, and then read the output stream. But the complexity is that the external program gives back its output in a piecemeal manner, with long delays between the outputs. In the main program I wa

Archetype Permission Errors with CMFBoard 2.2

2005-08-13 Thread Yuan HOng
Hi, I am trying to integrate the latest CMFBoard 2.2 with my Plone site (2.0.5 with Archetypes 1.3.3-final). I'd like to have my users to post anonymously with CMFBoard, so I added a forumNB of type 'open'. However, when an anonymous user tries to added a new Topic to the board, a bunch of error

Re: Archetype Permission Errors with CMFBoard 2.2

2005-08-13 Thread Yuan HOng
Ops. Sorry for posting the wrong list. On 8/13/05, Yuan HOng <[EMAIL PROTECTED]> wrote: > Hi, > > I am trying to integrate the latest CMFBoard 2.2 with my Plone site > (2.0.5 with Archetypes 1.3.3-final). I'd like to have my users to post > anonymously with CMFBoard, so

rounding of a decimal object

2006-07-18 Thread Yuan HOng
How can I round a decimal object to desired decimal position? It seems you have to use some unintuitive expression like: Decimal('7.325').quantize(Decimal('.01')) why not simply use Decimal('7.325').round(2) or just round(Decimal('7.325'), 2)? -- Hong Yuan 大管家网上建材超市 装修装潢建材一站式购物 http://www.home

Problem using epydoc with python2.4 and restructured text

2006-02-09 Thread Yuan HOng
I wish to document my project written in python2.4 with restructured text syntax. From the various python documentation tools it seems only epydoc supports rst as the documentation format. It seems however that epydoc, the last version being 2.1 released in 2004, doesn't support python2.4 well. I

Locale-specific string comparasion

2007-07-25 Thread Yuan HOng
Hi, The locale modules privides a strcoll function that can perform locale specific string comparision, and based on this, we can design custom comparision function for the sorting. However, this is quite cumbersome, for we have to derive custom classes from from the string / unicode objects, an

urllib2.open always send 'Accept-Encoding: gzip, deflate' under Windows

2009-02-03 Thread Yuan HOng
Hi, I wish to send a request without 'Accept-Encoding: gzip, deflate' in the request header. Under Linux, this is not a problem, I got 'Accept-Encoding: identity' by default. However, under Windows (XP SP3 with Python 2.5), no matter what I try, I always got 'Accept-Encoding: gzip, deflate' in th

Re: urllib2.open always send 'Accept-Encoding: gzip, deflate' under Windows

2009-02-03 Thread Yuan HOng
Hi, I got the reason. It has nothing to do with Python and its libraries. I have Symantec Client Security installed on the test machine, and it is modifying the content encoding header for outgoing http request, which is a strange thing. Disable the firewall and the problem goes away. -- Hong Y

How best to test functions which use date.today

2009-02-28 Thread Yuan HOng
HI, In my project I have several date related methods which I want tested for correctness. The functions use date.today() in several places. Since this could change every time I run the test, I hope to find someway to fake a date.today. For illustration lets say I have a function: from datetime

Re: How best to test functions which use date.today

2009-03-02 Thread Yuan HOng
Hello, Thanks for all the great ideas. Based on your input, I was able to solve my problem by way of a FakeDate in a fakedate module. In the testing module, before importing the tested module, I would load my fakedate module into sys.modules under the key 'datetime'. So when the tested module is

Py2exe and name space package

2008-06-10 Thread Yuan HOng
Hi, I used to freeze my application into Windows executibles using py2exe. Lately I started using several zope packages in my application, like zope.interface. Now the freezed program can't run properly. Like the following example shows: My setup.py file: from distutils.core import setup import

Re: Py2exe and name space package

2008-06-10 Thread Yuan HOng
On 6/10/08, Mike Driscoll <[EMAIL PROTECTED]> wrote: > > I include the lxml package in some of my programs and I do so by > adding the following to the setup.py > > packages = ['lxml'] > > However, I'm not sure if what you want to add is truly a package. > Yours might go into the "includes" direct

Decimal vs Float comparasion

2008-05-05 Thread Yuan HOng
Hi, It seems decimal object will always be larger than float in comparasion, which goes against common sense: >>> from decimal import Decimal >>> a = Decimal('0.5') >>> a > 9 False >>> a > 9.0 True It seems to me that rather than allowing this to happen, comparasion between the two shoul