Похожие чаты

Someone knows more about the @classmethod decorator? def decorator(func):

setattr(func, '_special_attr_', 'something something')
return func
# end def


class Foo(object):
@decorator
@classmethod
def method_one(cls, gnerf):
return gnerf
# end def
# end class

For some reason Foo.method_one._special_attr_ is unset.

If I switch however the @classmethod one to be outermost, i.e.

@classmethod
@decorator
def method_two(cls, gnerf):
return gnerf
# end def

that would work. Any clue why that is happening, and how I can support the first one as well?

1 ответов

3 просмотра

That's actually because a classmethod is not really a function object anymore

Похожие вопросы

Обсуждают сегодня

Типа вызывать GetParent и проверять на соответствие GetModuleHandle?
The Bird of Hermes
67
Do any of you guys have interesting projects one could join? I'm a Middle Full-Stack developer (JS/TS, React & Node)
Lev Shapiro
40
I read yesterday that in the near future most cryptos will be gone. It's like there is a lot of bullshit within the crypto sphere and this corruption some way is going to be c...
Kanah The Great
44
$res = json_decode($наша строка из респонса); $res1 = array_map(fn($o) => $o->name, $res->breadcrumbs[0]->entities); Как такое будет на Хаскеле?.. В начале весь джейсон, в ко...
Хаскель Моисеевич Гопник
27
Hello, I have a question. Can anyone help me? I want to make my cryptocurrencies, like Tron, untraceable by anyone, even government organizations. I was told that to do this,...
 ➛ Eᒪᕼᗩᗰ
14
В чем сила брат, в NASM или FASM?
Isaac Kleiner
18
I guess you did too?
OJohnny
13
Вопрос по диагностике ошибок (я знаю в чем, в данном конкретном примере, я знаю, как исправить, пример модельный, понятно, что в реальности бывает намного запутаннее). module...
ⰄⰎⰋⰐⰐⰑⰛⰤⰧⰧⰩⰄ ⰊⰑⰁⰓⰡⰛⰦⰕⰫ
11
А чем вам питонисты не угодили?😂
.
79
Hi - I have some ETH in lend for more than a week and I don’t see any Arb rewards. Is it not supposed to be dropped 2 times per week?
Greg
10
Карта сайта