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

2010-10-25 Thread Richard D. Moores
So I finally find a relevant example in the docs: The first example gave me some understanding and led me to revising my code to import urllib.request f = urllib.request.urlopen('http://www.marketwatch.com/invest

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

2010-10-25 Thread Sander Sweers
On 25 October 2010 18:19, Richard D. Moores 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. T

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

2010-10-25 Thread Richard D. Moores
And trying 2to3.py, which I've used successfully before, gets C:\P26Working\Finished\For2to3>2to3 -w -f urllib dollar2yen_rate_simple.py Traceback (most recent call last): File "C:\P26Working\Finished\For2to3\2to3.py", line 2, in from lib2to3.main import main File "C:\P26Working\Finished\

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

2010-10-25 Thread Richard D. Moores
On Mon, Oct 25, 2010 at 08:38, Sander Sweers wrote: > Have you actually tried reading the documentation? Of course. Though I can see why you wondered. >The _very_ first > section of the urllib documentation we have urllib.request.urlopen > [1]. Which looks to me what you are looking for as a re

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

2010-10-25 Thread Sander Sweers
On 25 October 2010 14:46, Richard D. Moores wrote: > I'd like to convert the script to 3.1, but I can't understand the docs > for the 3.1 urllib module. Please someone tell me what to do. > (Converting   'print rate'   to   'print(rate)'   I understand.) Have you actually tried reading the docume

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

2010-10-25 Thread Richard D. Moores
The lines below are the essence of a 2.6 script that gets the current USD/yen quote. I'd like to convert the script to 3.1, but I can't understand the docs for the 3.1 urllib module. Please someone tell me what to do. (Converting 'print rate' to 'print(rate)' I understand.) import urllib2