Skip to content

inspect.get_source(lambda) improvement #136521

Open
@dg-pb

Description

@dg-pb

Feature or enhancement

Proposal:

l1, v1, v2 = (lambda x: x), 1, 2
print(inspect.getsource(l1)[:-1])
# l1, v1, v2 = (lambda x: x), 1, 2

As the request is for the source of lambda, it might be convenient to extract only the lambda substring, not the whole line.

l1, l2 = (lambda x: x), (lambda x: (x[0] + 1) / 2)
print(inspect.getsource(l1)[:-1])
# l1, l2 = (lambda x: x), (lambda x: (x[0] + 1) / 2)

It might also be nicer to extract the substring of lambda that was requested in case of more than 1 lambda?

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy