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
Please don't ask meta questions like:
- Any user of $x here?
- Anyone used technology $y?
- Hello, I need help on $z!
Just ask about your problem directly! If you don't know what to ask, please read: http://catb.org/~esr/faqs/smart-questions.html
Perhaps depends on how it's being used
from dataclasses import dataclassЧитать полностью…
class Something:
def __init__(self, age: int):
self.age = age
@dataclass
class Data(Something):
name: str
d = Data(name="John", age=30)
print(d)
# Traceback (most recent call last):
# File "/home/user/test.py", line 14, in <module>
# d = Data(name="John", age=30)
# ^^^^^^^^^^^^^^^^^^^^^^^^^
# TypeError: Data.__init__() got an unexpected keyword argument 'age'
i made the dataclass for organization, is not all the code, there are some other parameters inside that dataclass
Читать полностью…
So why do you need a dataclass for something that is already supported on the library?
Читать полностью…
File <string>:4Читать полностью…
product_size: tuple[int, int]
^
IndentationError: unindent does not match any outer indentation level
@dataclassЧитать полностью…
class Background(ImageFile.ImageFile):
name: str
product_size: tuple[int, int]
image: ImageFile.ImageFile
:)
i know the existance of cpython library, nothing else 🤣😅
Читать полностью…
Not very helpful. Maybe a bit, considering the context.
Читать полностью…
Why this happens
- Something defines its own init(self, age: int)
- Data is a @dataclass and does not declare age as a field
- Dataclasses generate their own init and do NOT automatically include parameters from the parent init
If age is part of Data, declare it in the dataclass and let it handle everything.
from dataclass import dataclassЧитать полностью…
@dataclass
class Something:
age: int
@dataclass
class Data(Something):
name: str
d = Data(name="John", age=30)
print(d)
In [20]: im=Image.open("/home/user/Imágenes/mantra-machine-heliosphere.jpg")
In [26]: im.size
Out[26]: (1200, 1200)
Читать полностью…
yeah Image.ImageFile.ImageFile should has the size property
Читать полностью…
So... having this, yeah, i have questions, doesn't ImageFile.ImageFile have the size?
Читать полностью…
why dont you open ipython and see for yourself and inspect the object?
Читать полностью…
i used it (never used before) just for this semplification that i could do but idk if i can really do it
Читать полностью…