Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved _info function into docstring #5710

Merged
merged 1 commit into from Sep 13, 2021
Merged

Conversation

radarhere
Copy link
Member

In selftest.py, the shell commands in the docstring refers a number of times to an earlier function, _info. This PR suggests merging that function into the docstring as a lambda instead.

This should help give users the impression that they can just be up-and-running from shell, rather than "Wait, I run these shell commands from the example... but they refer to an external function?"

I also removed the load() command from _info, as I found it wasn't necessary.

@hugovk
Copy link
Member

hugovk commented Sep 13, 2021

I find defs clearer, and PEP 8 discourages lambdas:

Always use a def statement instead of an assignment statement that binds a lambda expression directly to an identifier:

# Correct:
def f(x): return 2*x
# Wrong:
f = lambda x: 2*x

The first form means that the name of the resulting function object is specifically 'f' instead of the generic '<lambda>'. This is more useful for tracebacks and string representations in general. The use of the assignment statement eliminates the sole benefit a lambda expression can offer over an explicit def statement (i.e. that it can be embedded inside a larger expression)

@hugovk hugovk merged commit dae542b into python-pillow:master Sep 13, 2021
@radarhere radarhere deleted the selftest branch September 13, 2021 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants