Re: Python GTK import error

2004-11-29 Thread Qianqian Fang
sorry keep bugging you guys, but this is somehow a wield problem that I am eager to solve. I checked the permission and it looks fine to me: lrwxrwxrwx 1 root root 26 Nov 28 04:06 /usr/lib/libgtk-x11-2.0.so.0 -> libgtk-x11-2.0.so.0.400.13 -rwxr-xr-x 1 root root 2862900 Oct 15 14:23 /usr/lib/l

How to get the type of an object?

2005-12-21 Thread Licheng Fang
I wrote a function with a list as its parameter. And the function has to perform different operations based on the datatypes of the elements. How can I decide whether an object is, say, a list or a string? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get the type of an object?

2005-12-21 Thread Licheng Fang
That helps. Thank you guys. -- http://mail.python.org/mailman/listinfo/python-list

How to configure proxy authentication when using urllib2?

2006-02-19 Thread Licheng Fang
I use a HTTP proxy to connect to Internet. When I run ulropen command I get HTTP Error 407: Proxy authorization required. Could anybody tell me how to resolve this? Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Nested Lists Assignment Problem

2006-04-26 Thread Licheng Fang
I wanna use nested lists as an array, but here's the problem: >>> a = [[0]*3]*3 >>> a [[0, 0, 0], [0, 0, 0], [0, 0, 0]] >>> a[0][0] = 1 >>> a [[1, 0, 0], [1, 0, 0], [1, 0, 0]] Could anybody please explain to me why three values were change? I'm bewildered. Thanks! -- http://mail.python.org/mail

Re: Nested Lists Assignment Problem

2006-04-26 Thread Licheng Fang
Dennis Lee Bieber wrote: > On 26 Apr 2006 01:13:20 -0700, "Licheng Fang" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > > > > Could anybody please explain to me why three values were change? I'm > > bewildered. Thank

extremely slow array indexing?

2006-11-30 Thread Grace Fang
Hi, I am writing code to sort the columns according to the sum of each column. The dataset is huge (50k rows x 300k cols), so i need to read line by line and do the summation to avoid the out-of-memory problem. But I don't know why it runs very slow, and part of the code is as follows. I suspect i

Re: extremely slow array indexing?

2006-11-30 Thread Grace Fang
Hi will,Thanks for your reply. The simplified code is as follows, and you can run it if you like. It takes 7 seconds to process 1000 rows, which is tolerable, but I wonder why it takes so long, because I also did one for loop through all of the same rows without accessing array, which only takes 1

Python and STL efficiency

2006-08-20 Thread Licheng Fang
Hi, I'm learning STL and I wrote some simple code to compare the efficiency of python and STL. //C++ #include #include #include #include #include using namespace std; int main(){ vector a; for (long int i=0; i<1 ; ++i){ a.push_back("What do you know?");

Re: Python and STL efficiency

2006-08-21 Thread Licheng Fang
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Licheng Fang > wrote: > > > Hi, I'm learning STL and I wrote some simple code to compare the > > efficiency of python and STL. > > > > //C++ > > #include > > #include

Re: Modules... paths... newbie confusion

2006-08-21 Thread Licheng Fang
MrBlueSky wrote: > I wonder if someone could clarify how Python "knows" where modules are > - or at least point to some documentation that might help me? Here's > what I've been trying: > > I've installed Python 2.4 Windows, and have also installed tkinter, > pmw, cx_Oracle, mssql and pytz (phew!

How to get the "longest possible" match with Python's RE module?

2006-09-11 Thread Licheng Fang
Basically, the problem is this: >>> p = re.compile("do|dolittle") >>> p.match("dolittle").group() 'do' Python's NFA regexp engine trys only the first option, and happily rests on that. There's another example: >>> p = re.compile("one(self)?(selfsufficient)?") >>> p.match("oneselfsufficient").gro

Re: How to get the "longest possible" match with Python's RE module?

2006-09-11 Thread Licheng Fang
MonkeeSage wrote: > Licheng Fang wrote: > > Basically, the problem is this: > > > > >>> p = re.compile("do|dolittle") > > >>> p.match("dolittle").group() > > 'do' > > >From what I understand, this isn'

Re: How to get the "longest possible" match with Python's RE module?

2006-09-11 Thread Licheng Fang
Oh, please do have a look at the second link I've posted. There's a table comparing the regexp engines. The engines you've tested probably all use an NFA implementation. MonkeeSage wrote: > Licheng Fang wrote: > > Hi, according to these regexp engine discussions, it'

Re: How to get the "longest possible" match with Python's RE module?

2006-09-11 Thread Licheng Fang
Thank you very much, Tim and Monkee. In fact, what I'm doing is handle a lot of regular expressions. I wanted to build VERY LONG regexps part by part and put them all into a file for easy modification and maintenance. The idea is like this: (*INT) = \d+ (*DECIMAL) = (*INT)\.(*INT) (*FACTION) = (*

Re: How to get the "longest possible" match with Python's RE module?

2006-09-12 Thread Licheng Fang
Bryan Olson wrote: > Licheng Fang wrote: > > Oh, please do have a look at the second link I've posted. There's a > > table comparing the regexp engines. The engines you've tested probably > > all use an NFA implementation. > > Unfortunately, the stuff a

Re: How to get the "longest possible" match with Python's RE module?

2006-09-12 Thread Licheng Fang
[EMAIL PROTECTED] wrote: > kondal wrote: > > > This is the way the regexp works python doesn't has anything to do with > > it. It starts parsing the data with the pattern given. It returns the > > matched string acording the pattern and doesn't go back to find the > > other combinations. > > I've

Re: How to get the "longest possible" match with Python's RE module?

2006-09-14 Thread Licheng Fang
Thank you guys. I've written a CYK parser and realized this is the right direction. It gives every possible interpretation of the string and I can retrieve whatever I want. -- http://mail.python.org/mailman/listinfo/python-list