mod_python load cx_Oracle error

2010-07-19 Thread li wang
It's quite weird when I import cx_Oracle in python interactive shell, it works perfectly. but when I import cx_Oracle in a *,py script, handled by mod_python.publisher, it keep reportint : ImportError: libclntsh.so.10.1: cannot open shared object file: No such file or directory Can I anyone have

Re: Python 2.6, File read() problems in Windows Xp

2009-05-08 Thread Li Wang
> (my smtp mail server has been down for a few hours, so you have some other > responses.) > > yes, as far as I can tell from the docs, the 'b' flag doesn't matter in > Unix/Linux. Note that I haven't actually been on a Unix machine since > starting with Python, but it matches what else I know. A

Re: Python 2.6, File read() problems in Windows Xp

2009-05-08 Thread Li Wang
2009/5/8 : > On May 8, 5:08 am, Li Wang wrote: >> Hi Dave: >> Thank you very much for you explanation:) >> >> > Chances are you forgot the "b" parameter to open(). Unnecessary in Unix, >> > it >> > tells the library to *not* translat

Re: Python 2.6, File read() problems in Windows Xp

2009-05-08 Thread Li Wang
2009/5/8 Scott David Daniels : > Li Wang wrote: >> >> So, if I am using python in Linux, do open('file', 'r') and >> open('file', 'rb') work the same way? > > You get identical results, but you ar lying to the reader of your code

Re: Python 2.6, File read() problems in Windows Xp

2009-05-08 Thread Li Wang
Hi Dave: Thank you very much for you explanation:) > Chances are you forgot the "b" parameter to open(). Unnecessary in Unix, it > tells the library to *not* translate \r\n to \n upon read, or the inverse > on write. In other words, with the "b" parameter, the file is read in > unchanged. So

Re: Python 2.6, File read() problems in Windows Xp

2009-05-08 Thread Li Wang
Hi: Problem solved Thank you very much, it works, It is my own problem:) All the best, Li 2009/5/8 Li Wang : > 2009/5/8 Chris Rebert : >> On Thu, May 7, 2009 at 10:04 PM, Li Wang wrote: >>> Hi all: >>> > >> the file, e.g. open("the_file.xls"

Re: Python 2.6, File read() problems in Windows Xp

2009-05-08 Thread Li Wang
2009/5/8 Chris Rebert : > On Thu, May 7, 2009 at 10:04 PM, Li Wang wrote: >> Hi all: >> > the file, e.g. open("the_file.xls", "rb") > Unlike *nix, Windows differentiates between binary and text files, > hence the need for the "b" flag to spec

Python 2.6, File read() problems in Windows Xp

2009-05-07 Thread Li Wang
Hi all: I am trying to read a non-text file as a string by using Python read(), however, it seems there is some thing wrong with it. I can use read() on text file correctly, but unable to read .xls file correctly. (The program can read any file correctly in Fedora 10) Any idea how to solve this p

How to measure the memory cost in Python?

2009-05-01 Thread Li Wang
Hi everyone: I want to measure the actual memory cost of a particular step in my program (Python program), does anyone know if there is some function in Python could help me to do this job? Or should I seek other tools to help me? Thank you very much! -- Li -- Time is all we have and you ma

Measure the memory cost in Python

2009-04-30 Thread Li Wang
Hi everyone: I want to measure the actual memory cost of a particular step in my program (Python program), does anyone know if there is some function in Python could help me to do this job? Or should I seek other tools to help me? Thank you very much! -- Li -- Time is all we have and you m

Re: How to locate the bit in bits string?

2009-04-28 Thread Li Wang
2009/4/29 Tim Chase : >>> You omit some key details -- namely how do you know that >>> "1001" is 4 bits and not "1001" (8-bits)? If it's a >>> string (as your current code shows), you can determine the >>> length. However, if they are actually ints, your code should work fine & >>> be O(1). >

Re: How to locate the bit in bits string?

2009-04-28 Thread Li Wang
2009/4/29 Tim Chase : >> I want to concatenate two bits string together: say we have '1001' and >> '111' which are represented in integer. I want to concatenate them to >> '100' (also in integer form), my method is: >> ('1001' << 3) | 111 >> which is very time consuming. > > You omit some key d

Re: How to locate the bit in bits string?

2009-04-28 Thread Li Wang
2009/4/29 Tim Chase : > Li Wang wrote: >> >> Hi: >> >> If I use an integer to represent bits: >> e.g. 99 represents '1100011' >> >> How can I locate, say the second bit of 99(i.e. '1')? >> >> Although bin(99)[4] coul

How to locate the bit in bits string?

2009-04-28 Thread Li Wang
Hi: If I use an integer to represent bits: e.g. 99 represents '1100011' How can I locate, say the second bit of 99(i.e. '1')? Although bin(99)[4] could be used to locate it, this transform cost too much memory (99 only needs 2Bytes, while string '1100011' needs 7Bytes). Anyone knows how to loca

Re: Efficient bits manipulation in Python

2009-04-28 Thread Li Wang
>> I have a bit-code :'1011011', how can I reverse it to '1101101'? >> >> Another question is I know how to transform the string '110' into >> integer 6, does anyone know how to transform integer 6 to a string >> '110'? >> >> Thank you very much:) > > Assuming that you are using 2.6: > > a = 0b1011

Efficient bits manipulation in Python

2009-04-28 Thread Li Wang
Hi: I have a bit-code :'1011011', how can I reverse it to '1101101'? Another question is I know how to transform the string '110' into integer 6, does anyone know how to transform integer 6 to a string '110'? Thank you very much:) -- Li -- Time is all we have and you may find one day you