Python - Noob Question - What does it mean "Giving one of the optional arguments"? -


what do? giving 1 of optional arguments:
ask_ok('ok overwrite file?', 2)

def ask_ok(prompt, retries=4, complaint='yes or no, please!'):     while true:         ok = input(prompt)         if ok in ('y', 'ye', 'yes'):             return true         if ok in ('n', 'no', 'nop', 'nope'):             return false         retries = retries - 1         if retries < 0:             raise ioerror('refusenik user')         print(complaint) 

see tutorial:
http://docs.python.org/py3k/tutorial/controlflow.html#default-argument-values

sets retries 2 , leaves complaint on default value 'yes or no, please!'. order of optional arguments in first line of function definition important.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -