text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
have to prompt the user for one thing at | 1,208 | 5.28 |
a time by manually calling that input | 1,211.039 | 4.161 |
function so what does this mean in real | 1,213.28 | 4.08 |
terms well let me go ahead back into vs | 1,215.2 | 5.04 |
code here and let me propose that we | 1,217.36 | 5.76 |
consider how we might leverage a certain | 1,220.24 | 4.64 |
module i'm going to go ahead and create | 1,223.12 | 3.28 |
a file called | 1,224.88 | 4.64 |
name.pi and i'd like to use a new module | 1,226.4 | 5.12 |
this time that's going to give me access | 1,229.52 | 3.76 |
to | 1,231.52 | 3.039 |
values that have been typed at that | 1,233.28 | 3.12 |
command line but what's this module | 1,234.559 | 3.36 |
going to be well this one's going to be | 1,236.4 | 4.159 |
called sys and sys short for system | 1,237.919 | 4.24 |
contains a whole lot of functionality | 1,240.559 | 4.081 |
that's specific to the system itself and | 1,242.159 | 4.321 |
the commands that you and i are typing | 1,244.64 | 3.76 |
the documentation for this module is at | 1,246.48 | 4.16 |
this url here and it lists all of the | 1,248.4 | 4.159 |
various functions and variables and the | 1,250.64 | 4.159 |
like that come with that module but | 1,252.559 | 3.521 |
we're going to focus on something a | 1,254.799 | 3.521 |
little more specific namely this thing | 1,256.08 | 4.76 |
here it turns out in the sys module in | 1,258.32 | 5.2 |
python there is a variable that just | 1,260.84 | 6.04 |
magically exists for you called argv it | 1,263.52 | 5.44 |
stands for argument vector which is a | 1,266.88 | 4.56 |
fancy way of describing the list of all | 1,268.96 | 4.64 |
of the words that the human typed in at | 1,271.44 | 3.52 |
their prompt | 1,273.6 | 3.84 |
before they hit enter all of those are | 1,274.96 | 5.44 |
seemingly magically provided to you via | 1,277.44 | 6.64 |
python in a variable called sys.rgv | 1,280.4 | 6.32 |
this variable is a list which means that | 1,284.08 | 4 |
the first element is going to be the | 1,286.72 | 2.72 |
first word that you type the second | 1,288.08 | 2.479 |
element is going to be the second word | 1,289.44 | 3.119 |
that you typed and so forth and by way | 1,290.559 | 4.081 |
of this list then can you figure out | 1,292.559 | 3.841 |
what words did the human actually type | 1,294.64 | 3.519 |
at the prompt and maybe use that to | 1,296.4 | 4.08 |
influence the behavior of your own | 1,298.159 | 4.081 |
program so what does this mean now in | 1,300.48 | 3.6 |
real terms well in this new tab called | 1,302.24 | 4.64 |
name dot pi let me go ahead and import | 1,304.08 | 5.52 |
sys within that sys module is going to | 1,306.88 | 5.52 |
give me access to sys.rgv but how might | 1,309.6 | 4.8 |
i want to use it well let's do this | 1,312.4 | 4.24 |
instead of writing a hello world program | 1,314.4 | 5.36 |
that all of these times has just looked | 1,316.64 | 5.519 |
for the return value of input to figure | 1,319.76 | 4.64 |
out what the user wants me to print | 1,322.159 | 3.921 |
let's go ahead and just expect the user | 1,324.4 | 3.44 |
to tell us when they run the python | 1,326.08 | 4 |
program itself what their name is and | 1,327.84 | 3.76 |
suppose this time i'd like to generate a | 1,330.08 | 3.76 |
whole bunch of name tags initially just | 1,331.6 | 4.319 |
one and in the us here it's very common | 1,333.84 | 3.6 |
to wear a sticker on your lapel that | 1,335.919 | 3.76 |
says hello my name is david so i want to | 1,337.44 | 4 |
print out some text that resembles that | 1,339.679 | 3.521 |
the idea being maybe i could enhance | 1,341.44 | 3.599 |
this program someday to even send that | 1,343.2 | 3.2 |
text straight to the printer and | 1,345.039 | 3.681 |
dynamically generate those name tags | 1,346.4 | 4 |
well let me go ahead now and do this let | 1,348.72 | 3.52 |
me go ahead and print out as always | 1,350.4 | 3.44 |
hello but i'll say a little something | 1,352.24 | 2.88 |
more this time to make things more | 1,353.84 | 3.839 |
interesting hello my name is quote | 1,355.12 | 5.919 |
unquote and then after that i normally | 1,357.679 | 5.761 |
have been in the habit of calling input | 1,361.039 | 4.561 |
storing the return value in a variable | 1,363.44 | 4.479 |
and passing in the name of that variable | 1,365.6 | 4.24 |
here but i'm going to instead jump right | 1,367.919 | 3.161 |
to this | 1,369.84 | 5.28 |
sys.rv bracket one and that's it | 1,371.08 | 5.56 |
i'm going to have a program here that | 1,375.12 | 3.76 |
says hello my name is followed by | 1,376.64 | 6 |
whatever is in sys.rv bracket one and | 1,378.88 | 6 |
notice sis.rgv again is a list and | 1,382.64 | 4.08 |
recall from our discussion of loops and | 1,384.88 | 3.84 |
in turn list we use the square bracket | 1,386.72 | 4.88 |
notation to get at the various elements | 1,388.72 | 4.64 |
inside of a list all right let me go | 1,391.6 | 3.84 |
down now into my terminal window and run | 1,393.36 | 4.48 |
python of name dot pi but this time | 1,395.44 | 4.4 |
rather than just hit enter and wait for | 1,397.84 | 3.76 |
the program to prompt me for my name let | 1,399.84 | 3.92 |
me proactively just tell this program | 1,401.6 | 4.319 |
what my name is at the so-called command | 1,403.76 | 5.039 |
line here we go dav id separated with a | 1,405.919 | 5.281 |
space from the name of the file so that | 1,408.799 | 4.961 |
now when i execute python name dot pi | 1,411.2 | 6.16 |
david i see on the screen voila hello my | 1,413.76 | 5.919 |
name is david so based on this | 1,417.36 | 4.559 |
demonstration alone i think we can infer | 1,419.679 | 4.48 |
exactly what's going on in sys.rg even | 1,421.919 | 4 |
though it sounds certainly at first | 1,424.159 | 2.801 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.