I was following David's recommendation ( https://github.com/lisa-lab/pylearn2/pull/205#issuecomment-15421382 ) . One of the reasons for making this function was to replace the if statements like "hasattr(rng, 'randn')" . Now, the rng is always RandomState and thus it is going to have all methods we are ever going to use. Nevertheless, we still checked for them. That is the reason for typeStr, it just checks if the method actually exists. 

P.S. - I thought that the hasattr() if statements were just to determine if the rng object was a seed or a RandomState object. But David's recommendation on making special functions like rng_randn, rng_normal, etc implied otherwise.