PYTHON CHALLENGE (MIND BOGGLING) QUESTION. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 16

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.

10th Jul 2020, 8:45 AM
👑 Tchybooxuur!
👑 Tchybooxuur! - avatar
28 Answers
+ 19
👑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 👍
10th Jul 2020, 9:56 AM
ProfOduola🙏🇳🇬
ProfOduola🙏🇳🇬 - avatar
+ 14
Ambiguity in grammar.
10th Jul 2020, 8:49 AM
Ozair Khan
Ozair Khan - avatar
+ 9
Namit Jain Please explain more... 🙏 I think the question specifically said "function" and not method.
10th Jul 2020, 8:58 AM
👑 Tchybooxuur!
👑 Tchybooxuur! - avatar
+ 9
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.
10th Jul 2020, 8:59 AM
Rowsej
Rowsej - avatar
+ 9
👑 Prometheus 🇸🇬 I've seen multiple decorators being used myself... 👍🏼 I even tried my hands on one too. https://code.sololearn.com/clyAxheYSTAv/?ref=app
11th Jul 2020, 5:34 PM
👑 Tchybooxuur!
👑 Tchybooxuur! - avatar
+ 8
Python On the second slide/page, it says at the bottom “A single function can have multiple decorators.”.
10th Jul 2020, 8:49 AM
Rowsej
Rowsej - avatar
+ 8
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!
10th Jul 2020, 8:49 AM
Namit Jain
Namit Jain - avatar
+ 6
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... 🤔
10th Jul 2020, 8:56 AM
👑 Tchybooxuur!
👑 Tchybooxuur! - avatar
+ 6
Ozair Khan 😅 I think so too.
10th Jul 2020, 8:57 AM
👑 Tchybooxuur!
👑 Tchybooxuur! - avatar
+ 6
Rowsej Thanks. I think you are right... 👍🏼
10th Jul 2020, 9:02 AM
👑 Tchybooxuur!
👑 Tchybooxuur! - avatar
+ 6
No worries!
10th Jul 2020, 9:03 AM
Rowsej
Rowsej - avatar
+ 6
MiKoLa🔥3L17.6L16=>L18 Yea... I agree with you 👍🏼 ☺️😌 I've sent my part of the double storm though.
10th Jul 2020, 10:01 AM
👑 Tchybooxuur!
👑 Tchybooxuur! - avatar
+ 6
👑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.
11th Jul 2020, 8:46 AM
Akshay Panwar
Akshay Panwar - avatar
+ 5
We can use multiple decoraters on single function as well as we use multiple function on single decorater
10th Jul 2020, 10:20 AM
NAREN
NAREN - avatar
+ 5
Mikhail 😉😊 Thanks for contributing. I did a little draft in response to your request. See here. https://code.sololearn.com/clyAxheYSTAv/?ref=app
10th Jul 2020, 12:38 PM
👑 Tchybooxuur!
👑 Tchybooxuur! - avatar
+ 4
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
10th Jul 2020, 10:18 AM
NAREN
NAREN - avatar
+ 4
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. 🤷‍♂️
10th Jul 2020, 11:00 AM
👑 Tchybooxuur!
👑 Tchybooxuur! - avatar
+ 4
Nice topic, 👑Tchybooxuur! 👍👍🔥 My dear python friends, i thought i understand decorators😅 and theoretically i knew that there may be multiple decorators on a single function! BUT, once i tried to make several decorators for a single function - i failed🤦‍♂️ Please, if you understand this topic well - give me a clear example (code) where 2 or more decorators are used on a single function🙏
10th Jul 2020, 11:24 AM
Mikhail
Mikhail - avatar
+ 4
👑Tchybooxuur! Thank you! I’ve never seen 2 decorators in action before👍💪
10th Jul 2020, 12:42 PM
Mikhail
Mikhail - avatar
+ 4
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😅
11th Jul 2020, 9:02 AM
Mikhail
Mikhail - avatar