PYTHON CHALLENGE (MIND BOGGLING) QUESTION.
Question: A function can have only 1 decorator? Ans: False I don't know precisely why the right answer is False because I've seen lots of Python functions with one decorator. Someone help please.
7/10/2020 8:45:06 AM👑Tchybooxuur!
28 AnswersNew Answer
👑Tchybooxuur! PYTHON CHALLENGE (MIND BOGGLING) QUESTION. Question: A function can have only 1 decorator? Ans: False In my opinion too, the answer should be True! Obviously, a function can have ONLY 1 decorator, it is not compulsory that a function should have more than 1 decorator, though it is possible for a function to have more than 1 decorator 😃 The grammar here is the major problem Perhaps, better put, the question could have read.... "A function cannot have more than 1 decorator" Then Answer: False should be the correct answer 👍
Ambiguity in grammar.
Namit Jain Please explain more... 🙏 I think the question specifically said "function" and not method.
👑 Prometheus 🇸🇬 I've seen multiple decorators being used myself... 👍🏼 I even tried my hands on one too. https://code.sololearn.com/clyAxheYSTAv/?ref=app
I am not sure but: When you want to refer a function to another function and at the same time you want that function to be class method too!
The question is, “A function can have ONLY 1 decorator” A function can have one, or two, or three, or more, but the question is asking if there can be ONLY one decorator.
https://www.sololearn.com/learn/Python/2463/ On the second slide/page, it says at the bottom “A single function can have multiple decorators.”.
Rowsej "A single function can have multiple decorators." The way I understand this to be is that the function can have more than one decorators. This does not mean the function can't have one decorator... 🤔
Ozair Khan 😅 I think so too.
Rowsej Thanks. I think you are right... 👍🏼
MiKoLa🔥3L17.6L16=>L18 Yea... I agree with you 👍🏼 ☺️😌 I've sent my part of the double storm though.
👑Tchybooxuur! Clearly , The statement given to us is claiming that A function can have only 1 decorator According to this statement the functions with more than one decorator should not exist. But as we have seen many functions with more than one decorator So such type of functions can exist. So the final conclusion is that the statement given to us is a wrong statement. Thus the answer to this question is False. I hope you understand.
We can use multiple decoraters on single function as well as we use multiple function on single decorater
Mikhail 😉😊 Thanks for contributing. I did a little draft in response to your request. See here. https://code.sololearn.com/clyAxheYSTAv/?ref=app
Actually we use multiple decoraters now and then,for Suppose clients wants to returns the values in list and in that list values must be in upper case, but client has given the lower case
NARENDRA (Bigil) Ok. But this question in particular is nebulous. And it can be read to mean that there cannot be any instance where a function has only 1 decorator. Which is confusing because I've seen plenty functions with only 1 decorator. 🤷♂️
Akshay Panwar yes, you are right! But there is another side of this question. If question is: function can have only 1 decorator. And we decide to answer: False - this also may be treated as if we answer: No, function can not have only 1 decorator. And at this point we are wrong as well, because function really CAN have only 1 decorator, but also CAN have more than 1, or CAN have no decorators at all🤷♂️ So Tchybuxooor pointed very clearly that this question from challenges is not correct! p.s. hope you also understand😅
Akshay Panwar I understand your point. All I'm saying is, the grammar syntax could have been put together a bit more cleverly to avoid double meanings. Eg: Python functions cannot have more than 1 decorator. I think the inclusion of "only" in the syntax was sloppy.
I use multiple decorators in discord.py For example, @commands.cooldown(*args) @bot.command() async def command(ctx): #code It's allowed, just not the norm.