python | Unsorted

Telegram-канал python - Python

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

Subscribe to a channel

Python

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

Читать полностью…

Python

Read rule #3 please!

Читать полностью…

Python

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'

Читать полностью…

Python

i made the dataclass for organization, is not all the code, there are some other parameters inside that dataclass

Читать полностью…

Python

So why do you need a dataclass for something that is already supported on the library?

Читать полностью…

Python

It's not my fault if telegram doesn't indent.

Читать полностью…

Python

  File <string>:4
product_size: tuple[int, int]
^
IndentationError: unindent does not match any outer indentation level

Читать полностью…

Python

Are you giving me the code in pieces? xD

Читать полностью…

Python

oh sorry i didn't included it

Читать полностью…

Python

but before i used python default ide

Читать полностью…

Python

@dataclass
class Background(ImageFile.ImageFile):
name: str
product_size: tuple[int, int]
image: ImageFile.ImageFile

:)

Читать полностью…

Python

i know the existance of cpython library, nothing else 🤣😅

Читать полностью…

Python

like, create a minimal example

Читать полностью…

Python

that is what i normally do

Читать полностью…

Python

i think you can do it, but... should you xd

Читать полностью…

Python

Not very helpful. Maybe a bit, considering the context.

Читать полностью…

Python

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)

Читать полностью…

Python

you can inherit with a dataclass, no issue 🤷‍♀️

Читать полностью…

Python

In [20]: im=Image.open("/home/user/Imágenes/mantra-machine-heliosphere.jpg")
In [26]: im.size
Out[26]: (1200, 1200)

Читать полностью…

Python

yeah Image.ImageFile.ImageFile should has the size property

Читать полностью…

Python

So... having this, yeah, i have questions, doesn't ImageFile.ImageFile have the size?

Читать полностью…

Python

Just edit your post Haha

Читать полностью…

Python

@dataclass

right?

Читать полностью…

Python

you didnt put the decorator

Читать полностью…

Python

i always used vscode

Читать полностью…

Python

me who doesnt use an IDE

Читать полностью…

Python

the best Cpython cli

Читать полностью…

Python

sorry... whats ipython?

Читать полностью…

Python

why dont you open ipython and see for yourself and inspect the object?

Читать полностью…

Python

i used it (never used before) just for this semplification that i could do but idk if i can really do it

Читать полностью…
Subscribe to a channel