__builtin__ module in Python -


If I have a module test and I have to list all those functions, then I Do this:

  Import Test DIR (Test)   

Unless I import the module, I do not use the functions defined in them I will. / P>

But all the functions in the __Biltin___ module can be used without importing. But without the import __builtin __ I am not able to do a dir (__ builtin __) . Does this mean that we use the work without importing the whole module?

  __builtin__ import zip  to  

Is this something like the above? But if I do del zip , then I

error of name: name 'zip' is not defined

Can anyone please explain this behavior?

As explained, names in python are first solved by viewing in local area , Then in any enclosed area, then in module-level area and finally in the namespace of built-in So there are special cases inherent in the way they are not imported within the scope of their modules, but if no name is found anywhere, then Python should have it __ underlying __ Will look in

Note that you can access the content of this radius without importing it. To do this, a portable way

  import system print (DIR (sys.modules ["__ builtin__"]))   

in CPython, also

  print (dir (__ buildins__))   

but it is considered an implementation description and for other Python implementations or future versions May not be available.

Comments