Skip to content

bpo-37645: simplify __str__ of function objects#15295

Closed
jdemeyer wants to merge 1 commit intopython:mainfrom
jdemeyer:function_str
Closed

bpo-37645: simplify __str__ of function objects#15295
jdemeyer wants to merge 1 commit intopython:mainfrom
jdemeyer:function_str

Conversation

@jdemeyer
Copy link
Copy Markdown
Contributor

@jdemeyer jdemeyer commented Aug 14, 2019

Copy link
Copy Markdown
Contributor

@epicfaace epicfaace left a comment

Choose a reason for hiding this comment

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

Would repr(f) when f takes arguments also look like f()? In that case, it might be misleading (it would look like f takes no arguments)

@jdemeyer
Copy link
Copy Markdown
Contributor Author

I'm not changing repr(f) at all, only str(f). But yes, str(f) will always be f() regardless of the signature. Note that neither repr(f) nor error messages involving f write the signature, so I don't plan to add the signature either.

>>> def f(a, b): pass
>>> f
<function f at 0x7f9c6e259160>
>>> f(**1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: f() argument after ** must be a mapping, not int

@epicfaace
Copy link
Copy Markdown
Contributor

epicfaace commented Aug 23, 2019

Sorry, I meant str(f). My concern was just that printing out f() may cause the misleading impression that f takes no arguments, while that is not the case for <function f at 0x7f9c6e259160> (because it has no parentheses).

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 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 Apr 7, 2026
@vstinner
Copy link
Copy Markdown
Member

vstinner commented Apr 7, 2026

I don't think that this change is a good idea: #81826 (comment). There is no activity for 7 years, I close the issue.

@vstinner vstinner closed this Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants