Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #95996

Re: No request in module urllib ?

Path csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:module': 0.09; 'python': 0.10; 'explicitly': 0.15; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'helps!': 0.16; 'instead:': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'subject:urllib': 0.16; 'url:example': 0.16; 'urllib': 0.16; 'wrote:': 0.16; 'attribute': 0.18; 'subject:request': 0.18; '>>>': 0.20; 'load': 0.20; '2015': 0.20; '"",': 0.22; 'sep': 0.22; 'am,': 0.23; 'thanks,': 0.24; 'import': 0.24; '(most': 0.24; 'header:In- Reply-To:1': 0.24; 'module': 0.25; 'header:User-Agent:1': 0.26; "doesn't": 0.26; 'chris': 0.26; 'error': 0.27; 'fri,': 0.27; 'subject: ?': 0.27; 'skip:u 20': 0.28; 'traceback': 0.33; 'windows.': 0.33; 'file': 0.34; 'sometimes': 0.35; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'wanted': 0.37; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'hope': 0.61; 'skip:u 10': 0.61; 'more': 0.63; 'packages,': 0.66; 'chrisa': 0.84
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=CvRCCSMD c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=EBOSESyhAAAA:8 a=IkcTkHD0fZMA:10 a=QIhr-27iAAAA:8 a=LXGQjzePLCURgduAaAgA:9 a=QEXdDO2ut3YA:10
X-AUTH mrabarnett@:2500
Subject Re: No request in module urllib ?
To python-list@python.org
References <55E8FA34.8060600@telenet.be> <CAPTjJmpAF3F=ZxgK4PV+fkpJKMmo_rs+Zvg1mBnypztLY8u2Kw@mail.gmail.com> <55E8FF47.409@telenet.be>
From MRAB <python@mrabarnett.plus.com>
Date Fri, 4 Sep 2015 03:41:07 +0100
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0
MIME-Version 1.0
In-Reply-To <55E8FF47.409@telenet.be>
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 8bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.116.1441334470.8327.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1441334470 news.xs4all.nl 23741 [2001:888:2000:d::a6]:50383
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:95996

Show key headers only | View raw


On 2015-09-04 03:17, Vincent Vande Vyvre wrote:
> Le 04/09/2015 04:08, Chris Angelico a écrit :
>> On Fri, Sep 4, 2015 at 11:56 AM, Vincent Vande Vyvre
>> <vincent.vande.vyvre@telenet.be> wrote:
>>> Python 3.2.3 (default, Jun 18 2015, 21:46:42)
>>> [GCC 4.6.3] on linux2
>>> Type "help", "copyright", "credits" or "license" for more information.
>>>>>> import urllib
>>>>>> urllib.request.urlopen('http://example.org')
>>> Traceback (most recent call last):
>>>    File "<stdin>", line 1, in <module>
>>> AttributeError: 'module' object has no attribute 'request'
>>>
>>> Same error with Python 3.4.0
>> With packages, like this, you sometimes need to explicitly import the
>> piece you want. That way, the urllib module doesn't have to load
>> everything up just because you wanted one small part. Try this
>> instead:
>>
>> import urllib.request
>> urllib.request.urlopen('http://example.org')
>>
>> Hope that helps!
>>
>> ChrisA
> Thanks, that works with 3.4.0. No with 3.2.3
>
It works for me with Python 3.2.5 on Windows.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: No request in module urllib ? MRAB <python@mrabarnett.plus.com> - 2015-09-04 03:41 +0100

csiph-web