Похожие чаты

I'M applying a decorator on a method inside of a

class, how do i get that class inside of the decorator? i tried calling dir() on the method but i didn't find anything useful

14 ответов

32 просмотра
artemetra 🇺🇦-[less active] Автор вопроса

i can use func.__qualname__ to find the name of the class, but i'm looking for getting an actual reference to that class

artemetra 🇺🇦 [less active]
i can use func.__qualname__ to find the name of th...

You can either set it as a classmethod. Or (if you really want to), you can access it with: self.\_\_class\_\_ (without the backslashes, Cant find a way to display it correctly without them)

artemetra 🇺🇦-[less active] Автор вопроса
artemetra 🇺🇦 [less active]
here you go: self.__class__ 😁

I tried to make it as a code block. But it didn't work

artemetra 🇺🇦-[less active] Автор вопроса
shahar
You can either set it as a classmethod. Or (if yo...

do i set it as classmethod before or after my decorator? @classmethod @my_decorator def some_func(...) vs @my_decorator @classmethod def some_func(...)

artemetra 🇺🇦-[less active] Автор вопроса
shahar
second one

yeah, thanks :D i'll try out both the classmethod and the __class__

shahar
second one

so what is the difference btw them

You can apply decorators to classes too. But why do you want to access the method's class with the decorator, idk what are you trying to do, but it looks like it can get really messy quickly if you do that

artemetra 🇺🇦-[less active] Автор вопроса
Link 🪈
You can apply decorators to classes too. But why d...

i know i can apply decorators to classes too and i'm actually using that. i'm trying out different solutions/desings as i'm currently very early in my project and unsure what's the best way to achieve what i need, thank you though

Link 🪈
You can apply decorators to classes too. But why d...

does decorating a whole class means decorating the constructor

Fan / Ac
does decorating a whole class means decorating the...

You could even create a subclass of the decorated class inside the decorator and return it.

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

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

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта