Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. # I like using pprint function for printing stuff as makes more human readble
  2. from pprint import pprint
  3.  
  4. # Importing os library for example
  5. import os
  6.  
  7. # for a module object: the module's attributes.
  8. # for a class object: its attributes, and recursively the attributes of its bases.
  9. # EXAMPLE: Print all the modules of os and os.walk
  10. pprint (dir(os))
  11. pprint(dir(os.walk))
  12.  
  13. # This is another way to get information about an object's module and atrributes
  14. # I like this better as this will give you a better sense of if the method of an object is actually a functions or an attribute
  15. # The means I find out easier if I need to use () and pass some arguments or I don't need to use parantesies and it's just an attributes
  16. # This also show where this module lives on disk and more
  17. pprint(help(os))
  18. # EXAMPLE: print an attribute of an object
  19. pprint(os.name)
  20. # EXAMPLE: print an method of an object
  21. pprint(os.times())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement