hello (I hope my english is not so bad),Your English is quite good. In future, though, please try to make your
subject line say a bit more about the problem - we *all* need help!
I'm doing a training course and I'm a newbie in Python. My problem :When you define a function or a method (using the def statement) you can
I have a form, and when I click, I make an update. But all the parameters
are all required to make the update. So I'd like to put in my code something
like [optional]...
My code (simplyfied) :
prg.ev_ind_update(wf_pk_ev_ind=wf_pk_ev_ind,wf_fon ction=wf_fonction,wf_nom=wf_nom)
and so, when I put nothing in wf_nom, it put me that error :"the parameter
wf_nom...was omitted from the request...". But sometimes, wf_nom is not
required !
Thanks to help a poor young boy
specify default values for arguments. A simple example:
... return a*b>>def fun(a, b=3):
...
9>>fun(3)
21>>fun(7)
28>>fun(7, 4)
21>>fun(a=7)
36>>fun(a=3, b=12)
Traceback (most recent call last):>>fun(b=99)
File "<stdin>", line 1, in <module>
TypeError: fun() takes at least 1 non-keyword argument (0 given)
You can see several things here:>>>
1. When you call a function you do not *have* to give thte names of the
arguments - they can be matched by position.
2. When you define a function you can specify a default value for one or
more arguments (these argument have to appear *after* the ones for which
no default is defined)
3. If you don't provide a value for an argument that has no default then
you will receive an exception, which normally results in a traceback.
Hope this helps. Welcome to Python, and its friendly community.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Recent Ramblings http://holdenweb.blogspot.com