[function] explanation of pargs required #209
-
Hello, could you elaborate on the correct method to pass a variable to a user defined function? I am trying every combination of syntax I can think of to get the following to work, I want to pass the term 'apple' into the function when called so that apple is called as the prompt:
but I cannot make it work correctly, I apologise if this is obvious I do not have a coding background but am enjoying using unprompted. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @mrkrunkles, Thank you for reaching out. Let me try to address your question about using custom arguments with
Notice that 1) we do not use commas here and 2) in order to retrieve the value of Now we can More importantly, we can override the value of
...which will cause the function to return I hope that makes sense. Please let me know if you have any other questions. |
Beta Was this translation helpful? Give feedback.
Hi @mrkrunkles,
Thank you for reaching out.
Let me try to address your question about using custom arguments with
[function]
- it's a little complex, so bear with me:Pargs, or positional arguments, can be passed into
[function]
to set boolean (i.e. true/false) variables to True. For example, if you declare[function my_func some_parg]
, and then[call my_func]
, the variablesome_parg
will automatically be True and ready for use within your function.I think what you're looking for are kwargs, or keyword arguments. You can set these to anything you want and you can give them default values. Let's modify your example: