Re: how to change sys.path?

2006-05-24 Thread Ju Hui
yes, we can add path to PYTHONPATH,but how to remove some items?
my sys.path:
 import sys
 for x in sys.path:
... print x
...

D:\usr\local\lib\site-packages\setuptools-0.6a11-py2.4.egg
D:\usr\local\lib\site-packages\clientcookie-1.3.0-py2.4.egg
c:\temp
C:\WINDOWS\system32\python24.zip
C:\Documents and Settings\phpbird
D:\usr\local\DLLs
D:\usr\local\lib
D:\usr\local\lib\plat-win
D:\usr\local\lib\lib-tk
D:\usr\local
D:\usr\local\lib\site-packages


the value of
HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.4\PythonPath
D:\usr\local\Lib;D:\usr\local\DLLs;D:\usr\local\Lib\lib-tk;

the content are difference, how to remove
C:\WINDOWS\system32\python24.zip
or
D:\usr\local\lib\site-packages\clientcookie-1.3.0-py2.4.egg
?

thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


how to change sys.path?

2006-05-23 Thread Ju Hui
is python search module by paths in sys.path?
how to change it manuallly?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to change sys.path?

2006-05-23 Thread Ju Hui
yes, I mean I want change the sys.path value and save it for next
using.
I can change the value of sys.path, but I can't save it permanently.
There is no python_path environment on my pc, what the relationship
between it and the sys.path?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to change sys.path?

2006-05-23 Thread Ju Hui
yes, we can change PYTHONPATH to add some path to sys.path value, but
how to remove item from sys.path?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting URL's

2006-05-19 Thread Ju Hui
use 
htmlparser or regular expression

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to remove 50000 elements from a 100000 list?

2006-05-06 Thread Ju Hui
to Andrew Gwozdziewycz:
Real humor...
Peter Otten:
thanks your reminder, in my project, a will a superset of b.
so symmetric_difference equals difference.
thank you all again!

-- 
http://mail.python.org/mailman/listinfo/python-list


how to remove 50000 elements from a 100000 list?

2006-05-05 Thread Ju Hui
I want to remove about 5 elements from a list,which has 10
elements.
sample code like below:

 a=range(10)
 b=range(4)
 for x in b:
... a.remove(x)
...
 a
[4, 5, 6, 7, 8, 9]

when a and b is small size, it will finished quickly, but when a and b
have many elements.
such as:
 a=range(10)
 b=range(5)
 for x in b:
... a.remove(x)
...
it will very slowly. Shall I change to another data structure and choos
a better arithmetic?
any suggestion is welcome.
thanks a lot!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to remove 50000 elements from a 100000 list?

2006-05-05 Thread Ju Hui
cool!
thanks you all!
I choose
a=set(range(10))
b=set(range(5))
a.symmetric_difference(b)
certainly,the real data not range(), I am satisfied the performance of
set.difference

thank you all again!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to use socks5 proxy in pycurl?

2006-04-20 Thread Ju Hui
sorry, I can'y find sample python code there.
I don't know how to set PROXYTYPE..

:(

-- 
http://mail.python.org/mailman/listinfo/python-list


how to use socks5 proxy in pycurl?

2006-04-18 Thread Ju Hui
import pycurl
c = pycurl.Curl()
c.setopt( pycurl.URL, 'http://www.test.com/test.html' )
import StringIO
b = StringIO.StringIO()
c.setopt( c.WRITEFUNCTION, b.write )
c.setopt( c.FOLLOWLOCATION, 1 )
c.setopt( c.MAXREDIRS, 5 )
c.setopt(c.PROXY,'www.test.com:1080')
#c.setopt(c.PROXYTYPE,'SOCKS5')
c.setopt(c.PROXYUSERPWD, 'user:pass')
c.perform()
print b.getvalue()


how to use socks5 proxy in pycurl?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to use socks5 proxy in pycurl?

2006-04-18 Thread Ju Hui
No one use this function?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I wanna use urllib2 to get a page with a socks 5 proxy, who can give me a sample code ?

2006-04-12 Thread Ju Hui
thanks a lot!

-- 
http://mail.python.org/mailman/listinfo/python-list


how to install PYCURL 7.15.2 on windows 2003?

2006-04-12 Thread Ju Hui
I download it from http://pycurl.sourceforge.net/
and then extract it to  D:\usr\pycurl-7.15.2
then
D:\usr\pycurl-7.15.2setup.py install --curl-dir=d:\usr\pycurl-7.15.2
Using curl directory: d:\usr\pycurl-7.15.2
Traceback (most recent call last):
  File D:\usr\pycurl-7.15.2\setup.py, line 197, in ?
assert os.path.isfile(o), o
AssertionError: d:\usr\pycurl-7.15.2\lib\libcurl.lib

how to install it?who can give me help? thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


how to print without blank?

2006-04-09 Thread Ju Hui
I want to print 3 numbers without blank.
 for x in range(3):
... print x
...
0
1
2
 for x in range(3):
... print x,
...
0 1 2

how to print
012
?

thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to print without blank?

2006-04-09 Thread Ju Hui
thank you all. IT's very helpful to me.
 import sys
 def no_space_before(x):
... sys.stdout.softspace = 0
... return x
...
 for x in range(3):
... print no_space_before(x),
...
012

-- 
http://mail.python.org/mailman/listinfo/python-list


I wanna use urllib2 to get a page with a socks 5 proxy, who can give me a sample code ?

2006-04-09 Thread Ju Hui
I wanna use urllib2 to get a page with a socks 5 proxy,who can give me
a sample code ?

example,
the proxy server is :123.123.123.123
and the port is :1080
and the username/password is : user/pass
I want to open http://www.google.com

how to write this kind of  script? 
thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I wanna use urllib2 to get a page with a socks 5 proxy, who can give me a sample code ?

2006-04-09 Thread Ju Hui
thanks, I will try pycurl.

-- 
http://mail.python.org/mailman/listinfo/python-list


how to use urllib2 to get a page with a socks 5 proxy?

2006-04-07 Thread Ju Hui
example,
the proxy server is :123.123.123.123
and the port is :1080
and the username/password is : user/pass
I want to open http://www.google.com


how to write this script?
thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


is there any bug in this multi-thread script?

2006-04-05 Thread Ju Hui
I wrote a script to do work with multi-thread in a queue reference
others code.
Is there any bug in this script?
another question is : when we call start to run one thread extends from
threading, it will call a join() by itself? I want to monitor the
qsize() to ensure all work are finished. but when I commented the
#code start
while q.qsize()0:
time.sleep(0.1)
#code end
it works well too.
any response is welcome.
Thanks a lot.

#code start

#!/usr/bin/env python
import Queue
import threading
import time
import random

q=Queue.Queue(0)
NUM_WORKERS = 3

class MyThread(threading.Thread):
A worker thread.
def __init__(self, input, worktype):
self._jobq = input
self._work_type = worktype
threading.Thread.__init__(self)
def run(self):

Get a job and process it. Stop when there's no more jobs

while True:
if self._jobq.qsize()0:
job = self._jobq.get()
worktype=self._work_type
self._process_job(job,worktype)
else:
break
def _process_job(self, job,worktype):

Do useful work here.
worktype: let this thread do different work
1,do list
2,do item
3,,,

doJob(job)

def doJob(job):

do work function 1

time.sleep(random.random()*3)
print doing ,job
if __name__=='__main__':

print begin...
#put some work to q
for i in range(NUM_WORKERS*2):
q.put(i)
#print total job q's size
print job q'size,q.qsize()
#start threads to work
for x in range(NUM_WORKERS):
MyThread(q,x).start()
#if q is not empty, wait
#while q.qsize()0:
#time.sleep(0.1)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is there any bug in this multi-thread script?

2006-04-05 Thread Ju Hui
up...

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Installing Python 2.4 on RedHat

2006-04-05 Thread Ju Hui
install new version on differente location.
use ln -s to use new python.

-- 
http://mail.python.org/mailman/listinfo/python-list