Search code examples
pythonfunctionargumentsreturn-typedtype

Taking return type of a fuction as argument in python


I have come across gaussian_filter() function of Scipy.ndimage library of python which has its description as Description

It says that we can pass an array or a dtype as an argument 'output' to this function and in case a dtype is passed then the function will return array of given dtype.

I am surprised and curious to know how the argument 'output' works here and how can I make my own functions with return types passed as an argument to those functions.


Solution

  • You may want to check source code for the gaussian_filter function here and find out that for output it uses function _get_output from here. Check how it is built and you'll be able to make your own functions like this.