[SciPy-Dev] usage of inspect.getargspec ?

Travis Oliphant travis@continuum...
Thu Jan 5 23:15:06 CST 2012


What is an isn't Pythonic seems to be a matter of some debate.     I *really* like the idea of unifying those arguments.   That simplifies the interface considerably. 

I can understand the argument that it would be better to be explicit about it however.    I see a couple of options: 

	1) add a property to the function to indicate what kind of function it is --- a simple 'kind' attribute on the function
	2) wrap up the function as the callable of a Singleton Class --- one kind for each "type" of function call. 

-Travis


On Jan 5, 2012, at 10:35 PM, Nathaniel Smith wrote:

> On Thu, Jan 5, 2012 at 7:09 PM,  <josef.pktd@gmail.com> wrote:
>> triggered by the recent commit, I started to look a bit more at
>> inspect.getargspec
>> 
>> https://github.com/scipy/scipy/commit/c9c2d66701583984589c88c08c478e2fc6d9f4ec#L1R1213
>> 
>> Until now I have seen it mainly in convenience code were it makes it
>> easier for users but that I usually don't use, in this case it is part
>> of essential code.
>> 
>> The main problem with inspect.getargspec is that it gets easily
>> confused by `self` if it is an instance method and by keywords and
>> flexible arguments.
> 
> I have to say, to me the main problem is that the resulting API is
> really un-Pythonic and surprising. I would never expect a function to
> behave differently just because I changed some meaningless details of
> the *signature* of the callback that I pass in.
> 
> I would find this confusing and unidiomatic even in template-heavy
> C++, never mind Python... explicit > implicit and all that.
> 
> -- Nathaniel
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev



More information about the SciPy-Dev mailing list