[Tutor] Need help with converting script using 2.6's urllib2 to Python 3.1

Sander Sweers sander.sweers at gmail.com
Mon Oct 25 20:10:14 CEST 2010

On 25 October 2010 18:19, Richard D. Moores <rdmoores at gmail.com> wrote:
> Doing it your way,
> from urllib import request
> a = request.urlopen('http://www.marketwatch.com/investing/currency/CUR_USDYEN').read(20500)
> print(a[123:140])
> succeeds. Why?

Not sure how this exactly works but this is what I know. The
difference is that urllib is now a directory with files in it while
urllib2 was a single file. When you import <module> on a a single file
module normally all functions and classes are available to you.

Now that this is a directory some magic (or not?) has to happen in
__init__.py (read I also don't know). But I am sure someone here will
be able to explain this properly :-).


More information about the Tutor mailing list