{"id":11,"date":"2013-07-17T14:50:06","date_gmt":"2013-07-17T14:50:06","guid":{"rendered":"http:\/\/wifijanitor.net\/?p=5"},"modified":"2013-07-17T14:50:06","modified_gmt":"2013-07-17T14:50:06","slug":"to-argv-or-to-to-variable-is-it-really-a-question","status":"publish","type":"post","link":"http:\/\/www.wifijanitor.com\/?p=11","title":{"rendered":"To ARGV or to To Variable, is it really a question?"},"content":{"rendered":"<p>Ok, so it&#8217;s not the best title ever, considering, but what the heck.<\/p>\n<p>So still working through the Python lessons. So far it doesn&#8217;t seem too different from what I used to do with a shell\/bash script ( I inherited some and learned what they did. Then created some new ones based on them). Though the &#8216;language&#8217; does seem to be a bit easier, and I see how it might be easier to accomplish some things better.<\/p>\n<p>That being said, most of the lessons so far, are calling for argv values, for lack of a better term. With this you call the script with arguments after the file name:<\/p>\n<p><strong>ex17.py old.txt new.txt<\/strong><\/p>\n<p><a href=\"http:\/\/wifijanitor.com\/wp-content\/uploads\/2013\/07\/ex17.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-26\" src=\"http:\/\/wifijanitor.com\/wp-content\/uploads\/2013\/07\/ex17.png?w=440\" alt=\"ex17\" width=\"440\" height=\"322\" \/><\/a><\/p>\n<p><a href=\"http:\/\/wifijanitor.com\/wp-content\/uploads\/2013\/07\/theirs.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-31 size-full\" src=\"http:\/\/wifijanitor.com\/wp-content\/uploads\/2013\/07\/theirs.png\" alt=\"theirs\" width=\"422\" height=\"121\" \/><\/a><\/p>\n<p>So that does seem to work, so long as the person who calls the script knows what they are supposed to do.<\/p>\n<p><strong>Personally I prefer something more like this:<\/strong><\/p>\n<p><a href=\"http:\/\/wifijanitor.com\/wp-content\/uploads\/2013\/07\/ex17a.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-27\" src=\"http:\/\/wifijanitor.com\/wp-content\/uploads\/2013\/07\/ex17a.png?w=440\" alt=\"ex17a\" width=\"440\" height=\"534\" \/><\/a><\/p>\n<p><a href=\"http:\/\/wifijanitor.com\/wp-content\/uploads\/2013\/07\/mine.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-30\" src=\"http:\/\/wifijanitor.com\/wp-content\/uploads\/2013\/07\/mine.png\" alt=\"mine\" width=\"308\" height=\"295\" \/><\/a><\/p>\n<p>Yes it is more lines of code, but to me at least, it seems more user-friendly. I could have anyone call my script and it asks them for the file names vs expecting them to know what they are supposed to do.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ok, so it&#8217;s not the best title ever, considering, but what the heck. So still working through the Python lessons. So far it doesn&#8217;t seem too different from what I used to do with a shell\/bash script ( I inherited some and learned what they did. Then created some new ones based on them). Though &hellip; <a href=\"http:\/\/www.wifijanitor.com\/?p=11\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;To ARGV or to To Variable, is it really a question?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[34],"class_list":["post-11","post","type-post","status-publish","format-standard","hentry","category-python","tag-python"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.wifijanitor.com\/index.php?rest_route=\/wp\/v2\/posts\/11","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.wifijanitor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wifijanitor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wifijanitor.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wifijanitor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11"}],"version-history":[{"count":0,"href":"http:\/\/www.wifijanitor.com\/index.php?rest_route=\/wp\/v2\/posts\/11\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.wifijanitor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wifijanitor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wifijanitor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}