Abbie Normal · @abbienormal
86 followers · 1731 posts · Server floss.social

have predicates ?

Say I have a variable my_var

I know it contains an instance of dataclass A or an instance of dataclass B

Can I say

is_A(my_var) ?

#Python #dataclasses

Last updated 1 year ago

Anubhav · @anubhav
7 followers · 336 posts · Server hachyderm.io

Does setting default "list" (or a "dict" for that matter) gets easier
-- being able to assign the damn list while listing an attribute instead of via "field( defaultfactory )" & "__post_init__" --
in a class in later versions? Currently am stuck with the version meant for python 3.6.

#python #dataclasses

Last updated 2 years ago

Anubhav · @anubhav
7 followers · 336 posts · Server hachyderm.io

Re: hachyderm.io/@leonerd@fosstodo

@leonerd
Not with proliferation of ".dataclass" ...

# docs.python.org/3/library/data
from dataclasses import dataclass

@dataclass
class Thing:
attr :str

def show( it ):
print( it.attr )

some = Thing( attr = 'value' )
some.show()

#dataclasses #python

Last updated 2 years ago

Ianhopkinson · @ianhopkinson
306 followers · 498 posts · Server mastodon.social

I'm using a Python dataclass to store dataset metadata. This is nice because it means I control the metadata vocabulary. However, my linter complains the dataclass has too many attributes which makes me wonder if I'm going the right way.

I'm made a poll and would welcome your thoughts?

#python #dataclasses #datascience #DataMesh

Last updated 2 years ago

Glyph · @glyph
2052 followers · 1874 posts · Server mastodon.social

Every time I write a `class` statement in Python now, I wonder about this: blog.glyph.im/2023/02/data-cla

#python #dataclasses #programming

Last updated 2 years ago

Jeroen · @Schrooms
14 followers · 48 posts · Server fosstodon.org

After making a tool in , I came to a conclusion.. Nowadays every time I create a class I always use ... The only exception is literally a Exception 🤯

#python #dataclasses #dev #developer

Last updated 2 years ago

Hashtagueule · @hashtagueule
15 followers · 115 posts · Server mamot.fr