Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - default arguments in function

Tags:

python

urllib2

Looking at the python doc http://docs.python.org/library/urllib2.html

urllib2.urlopen(url[, data][, timeout])

So, I pass in a url, then optional data and timeout variables (from how I read it).

So if I want to pass a timeout, but not the data... whats the default variable for data? Do you just do,

urlopen('http://www.example.com/', , 5)

Thanks :)

like image 209
Wizzard Avatar asked Aug 07 '26 23:08

Wizzard


2 Answers

You use the parameter names:

urlopen('http://www.exmaple.com/', timeout=5)
like image 175
Adam Vandenberg Avatar answered Aug 10 '26 12:08

Adam Vandenberg


urlopen('http://www.example.com/',timeout=5)
like image 41
Steve Tjoa Avatar answered Aug 10 '26 13:08

Steve Tjoa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!