+ 1

Someone please explain the sentence:

from sys import argv script, filename=argv

25th Dec 2016, 7:20 PM
A_BMT
A_BMT - avatar
5 Antworten
+ 3
The first line import "argv" object from the module "sys" in the current namespace, so it's like we've declared a variable name "argv" and assign it an object. In this case, "argv" is the list of the command line arguments... The second line declare two variables "script" and "filename", and assign to them the two first element of the list "argv". So, we could deduce that the Python script which contains these lines ( say it's filename is "my_script.py" ) would be run with at least one arguments... You mean: why one and not two? Because argv[0] is the filename of the script running. If I call my script like that: python my_script.py argument1 argument2 We'll have in "argv": argv[0]=="my_script.py" argv[1]=="argument1" argv[2]=="argument2"
25th Dec 2016, 7:50 PM
visph
visph - avatar
+ 3
"A module is a file containing Python definitions and statements." https://docs.python.org/2/tutorial/modules.html
25th Dec 2016, 8:18 PM
visph
visph - avatar
+ 1
Thanks. Can you please briefly explain "module"
25th Dec 2016, 8:15 PM
A_BMT
A_BMT - avatar
+ 1
Thanks Great website by the way
26th Dec 2016, 9:31 AM
A_BMT
A_BMT - avatar
+ 1
Thanks Great website by the way
26th Dec 2016, 9:32 AM
A_BMT
A_BMT - avatar