{"id":667,"date":"1997-09-09T01:36:29","date_gmt":"1997-09-09T09:36:29","guid":{"rendered":"http:\/\/www.birdhouse.org\/betips\/?p=667"},"modified":"1997-09-09T01:36:29","modified_gmt":"1997-09-09T09:36:29","slug":"python-accessing-attributes","status":"publish","type":"post","link":"https:\/\/www.betips.net\/?p=667","title":{"rendered":"Python: Accessing attributes"},"content":{"rendered":"<p>Chris Herborth has done a magnificent job porting <a href=\"http:\/\/www.bebits.com\/app\/606\">Python<\/a>, and building additional Python modules that let you access the BFS database. However, the modules documentation doesn&#8217;t give a lot of usage examples, and it isn&#8217;t immediately obvious how to access particular attribs with the <a href=\"http:\/\/www.bebits.com\/app\/591\">fsattr module<\/a>.<br \/>\nThe following block will serve the same function as the shell&#8217;s <code>catattr<\/code> command, but in native Python:<\/p>\n<pre> attrs = BeOS.fsattr.read_attrs( path_or_filename ) ThisArtist = attrs.get( \"Audio:Artist\", ( 0, \"No artist\" ) )[1] <\/pre>\n<p>The value of &#8222;ThisArtist&#8220; will now equal the contents of the artist attribute for the MP3 or .ogg file in &#8222;path_or_filename&#8220;. The example also includes error correction so your script won&#8217;t hork if it hits an unattributed file.<br \/>\nProps to Chris for this example.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Chris Herborth has done a magnificent job porting Python, and building additional Python modules that let you access the BFS database. However, the modules documentation doesn&#8217;t give a lot of usage examples, and it isn&#8217;t immediately obvious how to access particular attribs with the fsattr module. The following block will serve the same function as [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[10],"class_list":["post-667","post","type-post","status-publish","format-standard","hentry","tag-scripting"],"_links":{"self":[{"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/posts\/667","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.betips.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=667"}],"version-history":[{"count":0,"href":"https:\/\/www.betips.net\/index.php?rest_route=\/wp\/v2\/posts\/667\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.betips.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=667"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.betips.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=667"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.betips.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=667"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}