Re: benchmark

2008-08-07 Thread jlist
I think what makes more sense is to compare the code one most
typically writes. In my case, I always use range() and never use psyco.
But I guess for most of my work with Python performance hasn't been
a issue. I haven't got to write any large systems with Python yet, where
performance starts to matter.

> That Python code is bad, it contains range() instead of xrange, the
> big loop is in the main code instead of inside a function, uses ==
> None, etc. That person can try this (with Psyco), I have changed very
> little, the code is essentially the same:


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


urllib fails to connect

2008-08-20 Thread jlist
I'm running ActiveState Python 2.5 on Windows XP. It used
to work fine. Today however I get (10061, 'Connection refused')
for any site I try with urllib.urlopen(). 


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


Re: urllib fails to connect

2008-08-20 Thread jlist
I found out why. I set a proxy in IE and I didn't know
ActiveState Python use IE proxy!

> I'm running ActiveState Python 2.5 on Windows XP. It used
> to work fine. Today however I get (10061, 'Connection refused')
> for any site I try with urllib.urlopen().


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


Re: urllib fails to connect

2008-08-20 Thread jlist
My guess is urllib.urlopen() wraps the wininet calls, which share
IE proxy settings.

> Perhaps IE's proxy settings are effectively setting the Windows system 
> networking proxy settings?


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


Re: urllib fails to connect

2008-08-20 Thread jlist
Thanks. My problem was not how to use a proxy server but how
to not use the IE proxy :)

BTW, I'm not a fan of the way urllib2 uses a proxy particularly.
I think it's really unneccesarily complicated. I think it should be
something like this:
def urlopen(url, proxy='')

And if you want to use a proxy, set one in the call.

> I found out why. I set a proxy in IE and I didn't know
> ActiveState Python use IE proxy!
>
> > I'm running ActiveState Python 2.5 on Windows XP. It used
> > to work fine. Today however I get (10061, 'Connection refused')
> > for any site I try with urllib.urlopen().
>

switching to urllib2, installing the proxy opener, worked for me.
here is the sample. variable names are self explanatory

import urllib2
proxy=urllib2.ProxyHandler({"http":'http://'+proxyuser+':'+proxypass+'@'+httpproxy})
opener=urllib2.build_opener(proxy, urllib2.HTTPHandler)
urllib2.install_opener(opener)
req = urllib2.Request(url, form, headers)
fd = urllib2.urlopen(req)
print fd.code, fd.info(), fd.read()

regards
Edwin


The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure.  If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof.  Thank you.



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