135201
You will be muted until you read the rules. Read them! @Rules_for_Python A group about the Python programming language. Offtopic things go here: @pythonofftopic Resources to learn python: @pythonres Group for Hy: @hylang Selenium: @SeleniumPython
after that, when you have all things clear, you can use/mix them together and you'll understand what @classmethod does
🤔 looks like you need to understand OOP concepts first, that's your first task
Читать полностью…
Honestly, idk. I just had my doubts because I don't know decorators very well.
Читать полностью…
the question here is "WHY are you using @classmethod ?"
anyone could link me a guide to use decorators? i don't understand when i should use them
this is my case:
class Foo:
elements = []
@classmethod
def _adder(self, new_elements):
self.elements.extend(new_elements)
@classmethod
def _remover(self, elements):
for e in elements: elements.remove(e) # Actually i don't remember exactly the method
def update_elements(self, elements, action):
match action:
case 'add': self._adder(elements)
case 'rmv': self._remover(elements)
If you are having issues installing it, post your question in the @pythonofftopic group; there might be people who can help you.
Читать полностью…
Setup issues go into @pythonofftopic. And you really should not use a Python version that does not receive any updates any more (unsupported).
Читать полностью…
well classmethod is a built-in, so might be a bit different with decorators in general. decorator itself basically "wrapper for functions" and its for any functions and not only class methods.
Читать полностью…
and if you want to learn about decorators you can do it separately, no need to mess with OOP on them
Читать полностью…
you dont need to use classmethod for your example above. classmethod used when you need a function that related to a class but not related with the class data. eg:
class Person:Читать полностью…
liver_count = 2
@classmethod
def has_liver(cls):
return True
def remove_liver(self):
if self.liver_count == 1: raise PersonNeedALiverError()
self.liver_count -= 1
Person.has_liver() # to use class method
p = Person()
p.remove_liver()
Because, as you can see from my code, the editor methods receive elements from an update method that calls them based on what needs to be done, so I thought they should be preceded by the @classmethod decorator.
Читать полностью…
@Inchidi told me i don't have to use @classmethod but i didn't understood the motivation and so when i should use it and the decorators in general
Читать полностью…
❎ clouded pardoned ㅤ [6468398014] for
1/3: [Python] [Automated] Rule 1️⃣: Speak English.
Nothing we can do about it. And it's the other around. Python does not support certain Windows versions.
Читать полностью…
Read this please:
http://www.catb.org/~esr/faqs/smart-questions.html
Please pythonn versiya 3.8 windows7 32 bit Please send
Читать полностью…