{"id":7530,"date":"2021-03-07T23:39:49","date_gmt":"2021-03-08T04:39:49","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=7530"},"modified":"2021-03-07T23:39:49","modified_gmt":"2021-03-08T04:39:49","slug":"python-dir","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=7530","title":{"rendered":"Python: dir"},"content":{"rendered":"<p>I am writing this down because I never manage to remember these two super useful functions that tells you what a variable is.<\/p>\n<p>iLastProcessedTimestamp = 0<br \/>\nwith open(&#8216;test.txt&#8217;) as f:<br \/>\niLastProcessedTimestamp = int(f.readline())<br \/>\nprint(dir(iLastProcessedTimestamp))<br \/>\nprint(type(iLastProcessedTimestamp))<\/p>\n<p>The type function tells you the variable&#8217;s class (in this case, int). The dir function tells you the attributes of the variable.<\/p>\n<p><a href=\"https:\/\/www.rushworth.us\/lisa\/?attachment_id=7531\" rel=\"attachment wp-att-7531\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7531\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2021\/03\/DirAndType.png\" alt=\"\" width=\"958\" height=\"150\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2021\/03\/DirAndType.png 958w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2021\/03\/DirAndType-300x47.png 300w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2021\/03\/DirAndType-768x120.png 768w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2021\/03\/DirAndType-750x117.png 750w\" sizes=\"auto, (max-width: 958px) 100vw, 958px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am writing this down because I never manage to remember these two super useful functions that tells you what a variable is. iLastProcessedTimestamp = 0 with open(&#8216;test.txt&#8217;) as f: iLastProcessedTimestamp = int(f.readline()) print(dir(iLastProcessedTimestamp)) print(type(iLastProcessedTimestamp)) The type function tells you the variable&#8217;s class (in this case, int). The dir function tells you the attributes of &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[664],"class_list":["post-7530","post","type-post","status-publish","format-standard","hentry","category-coding","tag-python"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/7530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7530"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/7530\/revisions"}],"predecessor-version":[{"id":7532,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/7530\/revisions\/7532"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}