[New-bugs-announce] [issue24056] Expose closure & generator status in function repr()

Nick Coghlan report at bugs.python.org
Sat Apr 25 08:13:53 CEST 2015


New submission from Nick Coghlan:

>From https://mail.python.org/pipermail/python-ideas/2015-April/033177.html, there are some additional details about functions that could be usefully exposed in the function repr, specifically whether or not it's a closure, and whether or not it's a generator function.

Proposed display:

    <function f at 0x7f7dad9f7bf8 (closure)>
    <function f at 0x7f7dad9f7bf8 (generator)>
    <function f at 0x7f7dad9f7bf8 (closure,generator)>

The Python level checks for the two flags:

closure: f.__closure__ is not None
generator: c.__code__.co_flags & inspect.CO_GENERATOR

Actual implementation would be in the C code at https://hg.python.org/cpython/file/default/Objects/funcobject.c#l569

----------
messages: 241994
nosy: ncoghlan
priority: normal
severity: normal
status: open
title: Expose closure & generator status in function repr()
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24056>
_______________________________________


More information about the New-bugs-announce mailing list