# Passing an additional argument to a function

**URL:** <https://discuss.huggingface.co/t/passing-an-additional-argument-to-a-function/25140>\
**Category:** 🔒 Gradio\
**Created:** [October 28, 2022, 1:52pm UTC](https://discuss.huggingface.co/t/passing-an-additional-argument-to-a-function/25140 "2022-10-28T13:52:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LittleWing](https://avatars.discourse-cdn.com/v4/letter/l/4af34b/32.png) [@LittleWing](https://discuss.huggingface.co/u/LittleWing)\
**Post date:** [October 28, 2022, 1:52pm UTC](https://discuss.huggingface.co/t/passing-an-additional-argument-to-a-function/25140/1 "2022-10-28T13:52:32Z")

</div>

Hi

Can I pass an additional argument that is not an input in a Button.click?

something like:  
`gr.clickbtn.click(fn=myfunction(aditional_argument`)

Thank you for your great support and for the developers for making Gradio!

---

<div class="post-metadata">

**Author:** ![freddyaboulton](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/freddyaboulton/32/32732_2.png) [@freddyaboulton](https://discuss.huggingface.co/u/freddyaboulton)\
**Post date:** [October 28, 2022, 2:46pm UTC](https://discuss.huggingface.co/t/passing-an-additional-argument-to-a-function/25140/2 "2022-10-28T14:46:34Z")

</div>

Hi @LittleWing ! Unfortunately, `click` does not support arbitrary \*\*kwargs. What are you trying to accomplish? There might be another way!

---

<div class="post-metadata">

**Author:** ![LittleWing](https://avatars.discourse-cdn.com/v4/letter/l/4af34b/32.png) [@LittleWing](https://discuss.huggingface.co/u/LittleWing)\
**Post date:** [October 28, 2022, 7:37pm UTC](https://discuss.huggingface.co/t/passing-an-additional-argument-to-a-function/25140/3 "2022-10-28T19:37:02Z")

</div>

Hi @freddyaboulton Thanks for the quick reply!

I’ll try to explain,

I’m trying to write a code that connects to various switches (Networking) in my organization  
I’m sending an api requests via the `requests` library.

I have 2 buttons:

1. ‘show selected switches version’
2. upgrade selected switches

lets say a user pressed button number 1 for switch x, the code will send a login api request which grabs the cookie for switch x  
if he will then press button number 2 to upgrade switch x the code will send another login api request  
resulting with a new cookie, which I don’t want

Because the `Button.click` binds one function per button I couldn’t find a way to bypass that there wont be a new request for every button.

Thanks

---

<div class="post-metadata">

**Author:** ![freddyaboulton](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/freddyaboulton/32/32732_2.png) [@freddyaboulton](https://discuss.huggingface.co/u/freddyaboulton)\
**Post date:** [November 3, 2022, 2:34pm UTC](https://discuss.huggingface.co/t/passing-an-additional-argument-to-a-function/25140/4 "2022-11-03T14:34:22Z")

</div>

Hi @LittleWing ! Sorry it took me a while to get back to you.

Can you use a gr.Variable/gr.State ([State In Blocks](https://gradio.app/state_in_blocks/)) to keep track of whether the first button is clicked before the second one?

---

<div class="post-metadata">

**Author:** ![LittleWing](https://avatars.discourse-cdn.com/v4/letter/l/4af34b/32.png) [@LittleWing](https://discuss.huggingface.co/u/LittleWing)\
**Post date:** [November 5, 2022, 4:03pm UTC](https://discuss.huggingface.co/t/passing-an-additional-argument-to-a-function/25140/5 "2022-11-05T16:03:21Z")

</div>

Hi,

Thank you for the reply and support!

Its certainly a valid option to try! 🙂 - I’ll give it a shot! , I will update if new issues arise

Thank you so much @freddyaboulton 🙂
