I am at exercise 41 and to be honest I am extremely confused. I don't know if it's because i've been looking at the damn thing for hours, if my brain is fried, or what?
I've gone over the below in prior chapters but for some reason this is not translating in english to me.
PHRASE_FIRST = False
if len(sys.argv) == 2 and sys.argv[1] == "english":
PHRASE_FIRST = True
What I think it's saying is that if "phrase_first" is false, read the list, if "phrase_first" is true then read the list in english? I don't know? I think it's the middle line that's really screwing me up here.
I need an english break down to get me back on track.
No, the code sets PHRASE_FIRST to False.
Then the sys.argv list is tested; if there are 2 values in that list, and the second value is equal to the string "english", then PHRASE_FIRST is rebound to True.
sys.argv is the list of command-line arguments; sys.argv[0] is the name of the script, and any extra elements in that list are strings passed in on the command line:
python script.py foo bar
becomes
['script.py', 'foo', 'bar']
in sys.argv. In this case, if you run the script with:
python script.py english
then PHRASE_FIRST is set to True, otherwise it remains False.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With