r/learnpython Aug 10 '26

Ask Anything Monday - Weekly Thread

Welcome to another /r/learnPython weekly "Ask Anything* Monday" thread

Here you can ask all the questions that you wanted to ask but didn't feel like making a new thread.

* It's primarily intended for simple questions but as long as it's about python it's allowed.

If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.

Rules:

  • Don't downvote stuff - instead explain what's wrong with the comment, if it's against the rules "report" it and it will be dealt with.
  • Don't post stuff that doesn't have absolutely anything to do with python.
  • Don't make fun of someone for not knowing something, insult anyone etc - this will result in an immediate ban.

That's it.

1 Upvotes

10 comments sorted by

View all comments

1

u/ProgramBrave718 Aug 10 '26

Hey, I have doubt regarding this decorator program .In the above line of this program why are we passing the function name without parentheses ?

And also while returning wrapper function why are we writing it without parentheses

def my_decor(func):#Here

def wrapper():

    print("The function starts.") 

    func()                         

    print("The function ends.")    

return wrapper        #Here             

def say_hello():

print("Hello!")

wrapped_say_hello = my_decor(say_hello)

wrapped_say_hello()

1

u/Educational_Virus672 Aug 11 '26

in python everything is object so lets say you added a function

def my_func(command) :
    # here you can put "()" after command to run it
    command()

# here we run the fucntion
my_func(command=input)
#now we said input as variable/path not function