Comment

Comment by heisenzombie

If you want a function that's private to a function in Python you _could_ also do:

    def foo(context):
    
        def bar(x):
            return x*2
        
        baz = bar(context)

... This is particularly idiomatic for higher order functions, but I think it can be useful for other things if used with restraint.

But if you have functions that only need to be called from one calling function then I why not just inline the code and eschew having a function at all. Long function bodies for the win!

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton