Function declaration in Python
Question: I am using Theano in Python. I have the following code:

    
    
    outtmp = trainfunc(some_parameters)
    

I cannot find any declaration of the `trainfunc` function, while I can only
find a piece of code before the previous one as:

    
    
    # Function compilation
    trainfunc = TrainFn1Member(some_other_parameters)
    

I can find the declaration of `TrainFn1Member` but the two functions
(`trainfunc` and `TrainFn1Member`) do not have the same signature (input
parameters).

What does this mean, and is the second code segment the declaration of
`trainfunc`?


Answer: Mostly when name starts with uppercase letter then it is class name (unless it
is completely upper cased, then it mostly means constant). There is no `new`
operator in Python so this naming pattern is pretty important to distinguish
functions from classes (anyway it is general pattern). I don't know Theano,
but I suppose that `TrainFn1Member` is a class that implements `__call__`
method, so you can call it's instance like a function. Search for `__call__`
in `TrainFn1Member` class definition.

* * *

UPDATE:

According to your comment, `TrainFn1Member` is a function (what is pretty
strange according to what I said above and what is not my idea ;)). In this
case it has to return some `callable` what means that it returns one of 3
things (I hope I have not missed anything):

  1. function (`def` or `lambda`)
  2. instance of class that implements `__call__`
  3. method of some object (function bound to some class instance)

As I don't know `Theano` at all, I can only suggest to search deeper being
aware of those above.. (and welcome to Hogwarts ;))

