CCing the list.

Please always use ReplyAll to include the list.

Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/



>________________________________
> From: #PATHANGI JANARDHANAN JATINSHRAVAN# <jatinshr...@e.ntu.edu.sg>
>To: Alan Gauld <alan.ga...@btinternet.com> 
>Sent: Monday, 22 July 2013, 17:14
>Subject: RE: [Tutor] Cannot understand what this means
> 
>
>Hi
>I have doubts only on the arguments part. 
>
>OK, But what about them?
Do you understand what command line arguments are?

> def main():
>
>>    # This command-line parsing code is provided.
>>    # Make a list of command line arguments, omitting the [0] element
>>    # which is the script itself.
>>    args = sys.argv[1:]


This fetches the command line arguments missing the first which is the program 
name.
Do you understand slicing? Do you understand how sys.argv works - its similar to
the argc, argv mechanism of  C++ which you've maybe seen before.

>>    if not args:

>>      print 'usage: [--summaryfile] file [file ...]'
>>      sys.exit(1)

The logic here says that if args is empty then print the message and exit

>>    # Notice the summary flag and remove it from args if it is present.
>>    summary = False
>>    if args[0] == '--summaryfile':
>>      summary = True
>>      del args[0]

I have no idea why this is here but for whatever reason he is setting 
the summary flag to True if the first argument was --summaryfile

Now, is there anything else you don't understand? 
The more specific you make your questions the better we can 
answer them. 
Alan G.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to