On Wed, Jun 12, 2013 at 2:26 AM, Peter Otten <__pete...@web.de> wrote:
> Applying these findings to your script: > > from contextlib import contextmanager > try: > # python-2.x > from urllib2 import urlopen > from ConfigParser import ConfigParser > > @contextmanager > def my_urlopen(url): > yield urlopen(url).fp > > except ImportError: > # python-3.x > from urllib.request import urlopen > from configparser import ConfigParser > import io > > @contextmanager > def my_urlopen(url): > resp = urlopen(url) > yield io.TextIOWrapper(resp.fp) > > server='http://www.lsc-group.phys.uwm.edu/~ram/files' > > cp = ConfigParser() > with my_urlopen('%s/latest.ini' % server) as fp: > cp.readfp(fp) > > print(cp.get('version', '10.8')) > > I've run it with 2.6, 2.7, 3.2, and 3.3. Thanks that's very helpful, I hadn't realised that .readfp() had been deprecated. Cheers Adam -- http://mail.python.org/mailman/listinfo/python-list