Cezary.Sz Cezary.Sz - 1 year ago 84
Python Question

Python, when import from module cmd I haven't all attribute

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'a adding printscreen of this.
Why can not I import all attribute?

enter image description here

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download