Defer

    In Python you can sort of achive the same thing by keeping the contentbetween the and the block short.

    Go

    1. package main
    2.  
    3. "os"
    4. )
    5.  
    6. func main() {
    7. defer f.Close()
    8. // you can now read from this
    9. // `f` thing and it'll be closed later
    10.