Re: argument problem in optparse

2009-03-21 Thread Qian Xu
John O'Hagan wrote: > action="callback", > callback=my_callback it works perfect. You made my day and thank you both ^^) -- http://mail.python.org/mailman/listinfo/python-list

argument problem in optparse

2009-03-20 Thread Qian Xu
Hi All, I have a problem with OptParse. I want to define such an arugument. It can accept additional value or no value. "myscript.py --unittest File1,File2" "myscript.py --unittest" Is it possible in OptParse? I have tried several combination. But ... Best regar

UnitTest break on failure

2009-02-10 Thread Qian Xu
, 1. go ahead, if a failure is occurred. 2. stop, if an error is occurred? Best regards, Qian Xu -- http://mail.python.org/mailman/listinfo/python-list

Re: pg_result_status() alternative?

2009-01-07 Thread Qian Xu
Gerhard Häring wrote: > What are you testing, really? "Normal" Python code should use a > PostgreSQL DB-API module or a wrapper on top of it, like SQLAlchemy. > > Generally, you shouldn't have to drop down to protocol-level functions, > unless you're developing a PostgreSQL adapter yourself. > >

Re: pg_result_status() alternative?

2009-01-07 Thread Qian Xu
Steve Holden wrote: > Without knowing the full details of that particular module I would > hazard a guess that any database errors will raise exceptions in Python. > No exceptions means your database operation worked fine. result status is not an exception. It means the information of frontend/bac

Re: string length problem?

2009-01-07 Thread Qian Xu
Qian Xu wrote: > Hi All, > > why the code > print len(u"»test«") > returns 8 instead of 6? > > Best regards > Qian I have solved the problem myself. # -*- coding: utf-8 -*- print len(u"»test«") --- or --- s = "»test«" print len(s.deco

string length problem?

2009-01-07 Thread Qian Xu
Hi All, why the code print len(u"»test«") returns 8 instead of 6? Best regards Qian -- http://mail.python.org/mailman/listinfo/python-list

pg_result_status() alternative?

2009-01-06 Thread Qian Xu
) How can I do the same thing in python (2.5)? Thanks in advance -- Qian Xu -- http://mail.python.org/mailman/listinfo/python-list

Re: print to console without a line break

2008-12-23 Thread Qian Xu
Lie Ryan wrote: > If you don't mind an extra space, you can use this: > > print 'Testing something ...', > # note the trailing comma Thanks. However, the contents will be saved in buffer and will not be shown until print "(last piece)" sys.stdout.flush() can solve this problem :-) -- http://ma

Re: print to console without a line break

2008-12-23 Thread Qian Xu
Albert Hopkins wrote: > On Tue, 2008-12-23 at 13:18 +, Lie Ryan wrote: > > Probably because your stdout is line-buffered. Try: > > sys.stdout.write("Testing something...") > sys.stout.flush() # flush the stdout buffer Thanks. This works for me ^^) -- http://mail.python.org/mailman/listinfo/

Re: print to console without a line break

2008-12-23 Thread Qian Xu
Qian Xu wrote: > Hello All, > > Is it possible to print something to console without a line break? > > I tried: > sys.stdout.write("Testing something ...") // nothing will be printed > time.sleep(1) > sys.stdout.write("done\n") // now, the whole

print to console without a line break

2008-12-23 Thread Qian Xu
e "Testing something ..." first. And after 1 second, to see "done" (with a line break) The only one solution I have found is to call "echo -n 'my_string'". But it is not nice. Because I have to escape all special chars in the string manually. Any advice? Best r

pg_result_status

2008-12-22 Thread Qian Xu
can I do the same thing in python (2.5)? Thanks in advance -- Qian Xu -- http://mail.python.org/mailman/listinfo/python-list