On 15/07/13 09:53, #PATHANGI JANARDHANAN JATINSHRAVAN# wrote:
websites. But now, there is a program from Google's Python Exercises
whose main() part is already given to you.
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:]
if not args:
print 'usage: [--summaryfile] file [file ...]'
sys.exit(1)
# Notice the summary flag and remove it from args if it is present.
summary = False
if args[0] == '--summaryfile':
summary = True
del args[0]
My problem is that I cannot understand anything in this main() module.
Nothing at all.
It sounds like you need a more basic tutorial then.
Do you really not know what
def main():
means?
Hint: its a function not a module...
And do you know what "command line arguments" are?
Or what sys.argv represents?
Do you understand sys.exit()?
I assume 'print' is self explanatory?
Does the 'if' test mean anything?
If you really don't understand any of those things
you need to find a more basic tutorial and work
through it. (You might try the first part of mine,
see below, as an example)
If you do understand those constructs, then you
understand quite a lot of main and need to ask
a more specific question.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor