Reputation: 963
Many different representation of parameters in python such as :
urllib2.urlopen(url[, data][, timeout])
urllib2.build_opener([handler, ...])
cookielib.MozillaCookieJar(filename, delayload=None, policy=None)
urllib2.urlopen(url[, data][, timeout])
and
urllib2.urlopen(url,data,timeout)
Does the first one means all the url ,data and timeout can be passed as list?
Upvotes: 0
Views: 255
Reputation: 798686
I know that the parameter in second method is a list
This is incorrect. Square brackets in command/function documentation denote optional parameters. Note that in Python order of parameters does matter, so you'll need to use keyword arguments to omit parameters in the middle.
urllib2.urlopen(someurl, somedata, sometimeout)
urllib2.urlopen(someurl)
urllib2.urlopen(someurl, somedata)
urllib2.urlopen(someurl, timeout=sometimeout)
urllib2.build_opener()
urllib2.build_opener(handler1)
urllib2.build_opener(handler1, handler2)
urllib2.build_opener(handler1, handler2, handler3)
Upvotes: 5
Reputation: 142156
It's standard notation for optional arguments... ie you may pass data, optionally followed by timeout, or as you have its name, pass timeout without data using timeout=...
Upvotes: 2