def html_tag( tag ):
def body( msg ):
print( "hi! :", msg )
def inn_body( msg1 ):
print( "hola: ", msg1 )
return inn_body
return body
h1 = html_tag( "h1" )
h1( "varshini" )
h1( "subiksha" )/// How do i access the inn_body()?
accessing a second level nested function
|
accessing a second level nested function
|
|
Aug-09-2020, 03:29 PM
def html_tag(tag):
def body(msg):
print("hi! :", msg)
def inn_body(msg1):
print("hola: ", msg1)
return inn_body
return body
h1 = html_tag("h1")
h1("varshini")
h1("subiksha")('inn_body')
Aug-09-2020, 03:40 PM
(This post was last modified: Aug-09-2020, 03:40 PM by deanhystad.)
I was going to (ok, did) ask why would you want to do such a thing. Is it to allow writing code like that used in Yoriz' example? Looks confusing to me.
Aug-13-2020, 06:57 AM
(Aug-09-2020, 03:40 PM)deanhystad Wrote: I was going to (ok, did) ask why would you want to do such a thing. Is it to allow writing code like that used in Yoriz' example? Looks confusing to me.No, I was getting a hang of closures concept in python and I wanted to know on how to access a nested fuction using the closure method. |
|
|
Users browsing this thread: 1 Guest(s)
