I see in a couple of bots this construction:
def main(*args): for arg in pywikibot.handleArgs(*args): etc.
Now, if I write instead of this def main(): for arg in pywikibot.handleArgs(): etc. the result seems to be just the same. I tried with valid global and with unique parameters as well. So, what is the difference? I know the theory that * means a variable width argument list, but if I omit it, the behaviour does not change.
Bináris said:
I see in a couple of bots this construction:
def main(*args): for arg in pywikibot.handleArgs(*args): etc.
Now, if I write instead of this def main(): for arg in pywikibot.handleArgs(): etc. the result seems to be just the same. I tried with valid global and with unique parameters as well. So, what is the difference? I know the theory that * means a variable width argument list, but if I omit it, the behaviour does > not change.
The behavior is the same if you run the script from the command line.
However, using (*args) also allows you the option of running the script from inside the Python interactive interpreter; for example, if you were running "replace.py Foo Bar -start:!", then you could "import replace" in the interpreter and run <code>replace.main("Foo", "Bar", "-start:!")</code>. This can be useful for debugging, among other things.
Russ
pywikipedia-l@lists.wikimedia.org