1"use strict";(self.webpackChunkdloranc_github_io=self.webpackChunkdloranc_github_io||[]).push([[5093],{2007:(t,n,e)=>{e.r(n),e.d(n,{assets:()=>l,contentTitle:()=>s,default:()=>p,frontMatter:()=>a,metadata:()=>r,toc:()=>m});var o=e(6070),i=e(5710);const a={title:"Command line arguments in Python",tags:["dsp2017","python"],image:"images/posts_thumbnails/python_arguments.png",description:"A post about how to handle arguments passed to a Python script from the command line. For this I used a very interesting library called docopt."},s=void 0,r={permalink:"/2017/04/09/command-line-arguments-in-python",editUrl:"https://github.com/dloranc/dloranc.github.io/tree/main/blog/2017/04-09-command-line-arguments-in-python.md",source:"@site/blog/2017/04-09-command-line-arguments-in-python.md",title:"Command line arguments in Python",description:"A post about how to handle arguments passed to a Python script from the command line. For this I used a very interesting library called docopt.",date:"2017-04-09T00:00:00.000Z",tags:[{inline:!1,label:"DSP 2017",permalink:"/tags/dsp-2017",description:"Posts related to the Daj Si\u0119 Pozna\u0107 2017 competition. It was a competition that involved running your own blog and developing a project."},{inline:!1,label:"Python",permalink:"/tags/python",description:"Posts about Parseltongue, i.e. Python."}],readingTime:2.645,hasTruncateMarker:!0,authors:[],frontMatter:{title:"Command line arguments in Python",tags:["dsp2017","python"],image:"images/posts_thumbnails/python_arguments.png",description:"A post about how to handle arguments passed to a Python script from the command line. For this I used a very interesting library called docopt."},unlisted:!1,prevItem:{title:"Reinforcement learning - what is it?",permalink:"/2017/04/16/reinforcement-learning-what-is-it"},nextItem:{title:"Five pools",permalink:"/2017/04/09/five-pools"}},l={authorsImageUrls:[]},m=[];function c(t){const n={code:"code",p:"p",pre:"pre",...(0,i.R)(),...t.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(n.p,{children:["Recently I was wondering how to implement arguments passed to the script from the command line in Python. You can do this very simply using ",(0,o.jsx)(n.code,{children:"sys.argv"})," from the standard library:"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"import sys\n\nif __name__ == '__main__':\n\tprint \"\\n\".join(sys.argv)\n"})})]})}function p(t={}){const{wrapper:n}={...(0,i.R)(),...t.components};return n?(0,o.jsx)(n,{...t,children:(0,o.jsx)(c,{...t})}):c(t)}},5710:(t,n,e)=>{e.d(n,{R:()=>s,x:()=>r});var o=e(758);const i={},a=o.createContext(i);function s(t){const n=o.useContext(a);return o.useMemo((function(){return"function"==typeof t?t(n):{...n,...t}}),[n,t])}function r(t){let n;return n=t.disableParentContext?"function"==typeof t.components?t.components(i):t.components||i:s(t.components),o.createElement(a.Provider,{value:n},t.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.