# Get a function into Python Script as an input?

**URL:** <https://forum.dynamobim.com/t/get-a-function-into-python-script-as-an-input/908>\
**Category:** Packages\
**Created:** [January 12, 2015, 3:28am UTC](https://forum.dynamobim.com/t/get-a-function-into-python-script-as-an-input/908 "2015-01-12T03:28:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mehmet\_Polat\_Diker](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@Mehmet\_Polat\_Diker](https://forum.dynamobim.com/u/Mehmet_Polat_Diker)\
**Post date:** [January 12, 2015, 3:28am UTC](https://forum.dynamobim.com/t/get-a-function-into-python-script-as-an-input/908/1 "2015-01-12T03:28:41Z")

</div>

Is there any way to get a function into Python Script as an input?

![fPython](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/9/92efcf84c18463ded9a17995a0be113c76d6ad5c.jpg)

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Peter\_Kompolschek](https://avatars.discourse-cdn.com/v4/letter/p/dec6dc/32.png) [@Peter\_Kompolschek](https://forum.dynamobim.com/u/Peter_Kompolschek)\
**Post date:** [January 12, 2015, 5:04am UTC](https://forum.dynamobim.com/t/get-a-function-into-python-script-as-an-input/908/2 "2015-01-12T05:04:39Z")

</div>

hi mehmet, yes of course you can use functions in python nodes!

1. internal functions are like:

def flunwrap(a):  
#load input flattened and Unwrapped  
for x in a:  
for y in x:  
elements.append(UnwrapElement(y))  
return elements

* * *

to use it, just call it like:

flunwrap(IN[0])

it is even possible to use external functions! that is what makes live a lot easier! 😉

how will it work?

1. create a path to your personal library:

libpath = 'd:/Daten/ARCHITEKTUR/DYNAMO/Python-Codes/'  
library = ‘[2015DynamoLibrary.py](http://2015DynamoLibrary.py)’

1. create the execfile reference:

execfile(libpath+library)

in your library file the syntax is like:

def flunwrap(a):  
"load input flattened and Unwrapped"  
for x in a:  
for y in x:  
elements.append(UnwrapElement(y))  
return elements

you see, almost the same as in a python node (as far as i found out using a comment in the first line of a definition in an external file will be handled as message and has to be embraced by “”)

greatest advantage in day to day use: less typing as most of your functionsf can easily be generalized.

better enviroment for python coding in external editors 🙂 🙂

&nbsp;

---

<div class="post-metadata">

**Author:** ![Andreas\_Dieckmann](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andreas_dieckmann/32/365_2.png) [@Andreas\_Dieckmann](https://forum.dynamobim.com/u/Andreas_Dieckmann)\
**Post date:** [January 12, 2015, 5:50am UTC](https://forum.dynamobim.com/t/get-a-function-into-python-script-as-an-input/908/3 "2015-01-12T05:50:01Z")

</div>

Passing nodes as functions to Python used to work in Dynamo 0.6.3 (and it was awesome!!!), but is currently not supported:

> **[DynamoDS/Dynamo](https://github.com/DynamoDS/Dynamo/wiki/Python-0.6.3-to-0.7.x-Migration#passing-functions-to-python)**
>
> Open Source Graphical Programming for Design. Contribute to DynamoDS/Dynamo development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Askbid](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@Askbid](https://forum.dynamobim.com/u/Askbid)\
**Post date:** [August 14, 2019, 10:49am UTC](https://forum.dynamobim.com/t/get-a-function-into-python-script-as-an-input/908/4 "2019-08-14T10:49:10Z")

</div>

Is it now possible to use Functions as inputs in python scripts?

---

<div class="post-metadata">

**Author:** ![adam\_bear1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/adam_bear1/32/13411_2.png) [@adam\_bear1](https://forum.dynamobim.com/u/adam_bear1)\
**Post date:** [August 14, 2019, 11:56am UTC](https://forum.dynamobim.com/t/get-a-function-into-python-script-as-an-input/908/5 "2019-08-14T11:56:57Z")

</div>

maybe this wasn’t the answer you were looking for…  
but it is is quite fun  
[node base python.dyn](https://forum.dynamobim.com/uploads/short-url/z2QERfPk8RAEbg8D6J5xdbbqWwF.dyn) (37.1 KB)

 ![nodeBasedPython](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/c/bc984d7bbd8039eff4b501d8e522914346daba7d.gif)
