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

Feature request: function to strip arguments from function call #128

Open
bersbersbers opened this issue Jun 2, 2023 · 1 comment
Open

Comments

@bersbersbers
Copy link
Contributor

Would the following be a useful addition to funcy?

def plain(x):
    """Creates a function accepting any args, but always returning x()."""
    return lambda *a, **kw: x()

Or can this be emulated using existing funcy functionality?

A use case for this is to connect a function to to a Qt (PySide) Signal that passes parameters that we do not need.

So instead of doing

            QLineEdit().textChanged.connect(
                lambda _unused_event_value_str: callback()
            )

one could do

            signal.connect(plain(callback))

ignore_args might be another fitting name.

@Suor
Copy link
Owner

Suor commented Jun 29, 2023

Maybe not sure this is of very general use though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants