# Fish argument not available inside the function

**URL:** <https://forum.itascainternational.com/t/fish-argument-not-available-inside-the-function/737>\
**Category:** Uncategorized\
**Tags:** fish\
**Created:** [September 5, 2022, 12:21pm UTC](https://forum.itascainternational.com/t/fish-argument-not-available-inside-the-function/737 "2022-09-05T12:21:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![juantello](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@juantello](https://forum.itascainternational.com/u/juantello)\
**Post date:** [September 5, 2022, 12:21pm UTC](https://forum.itascainternational.com/t/fish-argument-not-available-inside-the-function/737/1 "2022-09-05T12:21:30Z")

</div>

Good day to you all!

I am writing a fish function that takes an argument and calls a Python function that uses that argument, say:

```auto
def myFish(x)
command
 call "myPython.py"
endcommand
end

```

where inside `myPython.py` is a line of the sort:

```auto
x = it.fish.get("x")

```

but this returns an error

> \*\*\* Python error: ‘FISH variable not found.’

and indeed, if I issue `pause` inside the FISH function:

```auto
def myFish(x)

command
pause
 call "myPython.py"
endcommand
end

```

I see that `x` is not in my FISH Symbols.

What can I do to make the argument to my FISH function available? is this perhaps due to my argument not being global?

Thank you in advance,

---

<div class="post-metadata">

**Author:** ![Huy](https://avatars.discourse-cdn.com/v4/letter/h/c5a1d2/32.png) [@Huy](https://forum.itascainternational.com/u/Huy)\
**Post date:** [September 5, 2022, 2:38pm UTC](https://forum.itascainternational.com/t/fish-argument-not-available-inside-the-function/737/2 "2022-09-05T14:38:15Z")

</div>

Yes, as you said, x is not a global variable and it.get.fish doesn’t work. I don’t know why you need to call a python function inside fish function. But we usually use python as a super set to handle fish scripts.  
If you still want to get x, you can use the command pythonfile. But it’s just a hack, I don’t recommend

```auto
def myFish(x)
command
 pythonfile x = [x]
 call "myPython.py"
endcommand
end

```

---

<div class="post-metadata">

**Author:** ![juantello](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@juantello](https://forum.itascainternational.com/u/juantello)\
**Post date:** [September 5, 2022, 3:44pm UTC](https://forum.itascainternational.com/t/fish-argument-not-available-inside-the-function/737/3 "2022-09-05T15:44:59Z")

</div>

Oh ok, thank you, I just delcared a global FISH variable and that works with it.fish.get. Regarding your point of why nest python inside fish, it’s just due to my not being so familiar with fish to do some more complex things.

I use a python file (distributeStruts.py) to loop through a line in the model and find nodes that are near a given set of points in space to create struts by calling another fish function ‘createStrut’ with exact coordinates of deformed nodes - not sure if this is necessary. This is nested inside another fish function (struts(z)) that creates a whole line of struts just by giving it the argument z. I just made it work with declaring

```auto
def struts(z)
 global zGlobal = z
 command 
    call 'distributeStruts.py' ; <---- uses zGlobal
 endcommand
end

```

this is probably more complicated than it needs to, so if you have any suggestions to improve my fishing I would greately appreciate it.

Cheers,
