[Python-ideas] @return?

Masklinn masklinn at masklinn.net
Thu Apr 15 13:52:15 CEST 2010


On 15 Apr 2010, at 13:03 , Conrad Irwin wrote:
> 
> 
> On 04/15/2010 07:10 AM, Masklinn wrote:
>> On 15 Apr 2010, at 01:33 , Conrad Irwin wrote:
>>> I am also slightly against truly
>>> "anonymous" functions, if it doesn't fit inside a lambda, the name at
>>> least provides some compulsory documentation
>> 
>> Isn't that statement a bit disingenuous when considering that `for` or
>> `with` blocks can contain arbitrary complexity and not require any kind
>> of naming?
>> 
>>> and a reference point while debugging.
>> 
>> that can be useful, but again it's not like most python source provides
>> that.
> 
> The thing I fear is ending up with a stacktrace like:
> 
> Traceback (most recent call last):
>  File "a.py", line 10, in <module>
>    event('complete')
>  File "a.py", line 6, in event
>    def event(*args): [callback(*args) for callback in cbs]
> TypeError: <anonymous>() takes no arguments (1 given)
> 
> In general, it is going to take a while to find out what <anonymous> is,
> and where it came from, and why it has the wrong signature. Because you
> can't pass with/for blocks around there is little need for them to carry
> their documentation with them. Obviously it's not impossible, it's just
> not pleasant either.
I understand that fear, but there is no reason why the repr for the anonymous
def wouldn't include the file and line where the function was created, is
there?, e.g.

> TypeError: <anonymous at b.py:42>() takes no arguments (1 given)

something along those lines. Tracking those infos would be necessary for
debugging anyway.



More information about the Python-ideas mailing list