r/Python • • Nov 14 '17

Senior Python Programmers, what tricks do you want to impart to us young guns?

Like basic looping, performance improvement, etc.

1.3k Upvotes

629 comments sorted by

View all comments

Show parent comments

1

u/Arancaytar Nov 14 '17
    def f(x):
        # do something with x and params
    return f

I'm kind of surprised python hasn't added anonymous non-lambda functions yet.

1

u/[deleted] Nov 14 '17

Can you give a reasonable explanation for why you would need an anonymous function?

2

u/Arancaytar Nov 14 '17

Well, in this case it would save you a redundant temp variable (f).