trouble with urlopen in blender and ideone

As simple as

import urllib

f = urllib.urlopen("http://www.google.com")

(not the best in syntax color selection)

Doesn’t work in Blender. The error says to check the console for now, but I don’t see anything in the Python console window or the log window. This is on OS X.

Also, I tried the same code in ideone, but no luck there either.
Something else I should be doing?

you should use

bpy.ops.wm.url_open(url=“http://www.google.com/”)

Thanks. I will certainly give that a try - but, to understand, why not use urllib.urlopen ?

oh well, my suggested line opens the default browser on that url, what you wanna do is reading from a network address right? That’s of course not the same, but still, as python scripts block blender until finished, it’s not advised to do possibly long-asting I/O actions.

Anyway, if you wanna use urllib, make sure to check the python 3 docs, it changed a bit:

http://docs.python.org/3.3/library/urllib.request.html#module-urllib.request

so it’s

from urllib.request import urlopen
urlopen(…)

Thanks CoDEmanX - that worked well.