0

When I import module urllib in cmd I have only magic fuctions but when I import this module from Spyder I have all attribute.

I'm adding printscreen of this.

Why can not I import all attribute?

enter image description here

Luka Kerr
  • 3,750
  • 6
  • 31
  • 47
CezarySzulc
  • 1,486
  • 1
  • 10
  • 22

1 Answers1

0

To import all attributes of a module into the global namespace use from module import *.

While dir() simply lists the attributes of the global namespace, dir(module) lists the ones in the scope of the specific module.

Anyway, when you import urllib you can still reach all attributes if you specify the module name, e.g. urllib.request.

imant
  • 588
  • 5
  • 15
  • But in cmd when I import urllib and I'm trying to use urllib.request I have an AttributeError -> no attribute 'request' When I'm using spider every thing is ok – CezarySzulc Oct 02 '16 at 13:07
  • That is indeed the case. Simply use `import urllib.request` in your IDLE. For further reading check out http://stackoverflow.com/questions/22278993/attributeerror-module-object-has-no-attribute-request. – imant Oct 02 '16 at 13:12