Skip to content

gh-79037: Add signature and body expression to the repr of lambda#9647

Draft
serhiy-storchaka wants to merge 5 commits intopython:mainfrom
serhiy-storchaka:lambda-repr
Draft

gh-79037: Add signature and body expression to the repr of lambda#9647
serhiy-storchaka wants to merge 5 commits intopython:mainfrom
serhiy-storchaka:lambda-repr

Conversation

@serhiy-storchaka
Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka commented Sep 30, 2018

Comment thread Python/compile.c Outdated
if (!exprstr) {
return 0;
}
name = PyUnicode_FromFormat("<%U>", exprstr);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this, add C equivalent of, say,
if len(exprstr) > 36: exprstr = exprstr[0:36] + ' ...'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will only add more confusion, especially if the lambda is the part of other object. Most lambda expressions are relatively short, and if they are long, many users would prefer the full expression with balanced quotes and parentheses. We already have such issue with truncated regular expressions.

Copy link
Copy Markdown
Member

@iritkatriel iritkatriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has merge conflicts now.

@bedevere-bot
Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@hauntsaninja hauntsaninja changed the title bpo-34856: Make the repr of lambda containing the signature and body expression. gh-79037: Make the repr of lambda containing the signature and body expression. Feb 9, 2023
Copy link
Copy Markdown
Contributor

@furkanonder furkanonder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. It would be extremely beneficial for Lambda's repr to include the signature and body, particularly for debugging. @serhiy-storchaka Could you resolve the conflicts?

Comment thread Doc/whatsnew/3.8.rst Outdated
Comment thread Misc/NEWS.d/next/Core and Builtins/2018-09-30-21-15-54.bpo-34856.uQBZD7.rst Outdated
@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Feb 27, 2025
@StanFromIreland
Copy link
Copy Markdown
Member

Are you still working on this, I can fix the conflicts?

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Sep 21, 2025
@serhiy-storchaka serhiy-storchaka changed the title gh-79037: Make the repr of lambda containing the signature and body expression. gh-79037: Add signature and body expression to the repr of lambda Nov 8, 2025
@serhiy-storchaka serhiy-storchaka marked this pull request as draft November 8, 2025 21:34
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 1, 2026

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Jan 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Stale PR or inactive for long period of time. type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants