Explore tweets tagged as #DataClasses
@py4all
بايثون للجميع
6 months
نصيحة اليوم: استخدم dataclasses لإنشاء كائنات بيانات بسهولة. #بايثون #نصائح_برمجية
Tweet media one
0
1
4
@PemudaMaluku___
Reeeeeeeeeey!
2 months
this is a reminder for you to start using 'namedtuple'. it is way more lightweight than regular python class. alternative.> built-in : dataclass from dataclasses, for more type annotation.> 3rd party: pydantic.
Tweet media one
1
0
6
@bbelderbos
Bob Belderbos
16 days
TIL: You can force keyword-only arguments in dataclasses (#Python 🐍 3.10+) 🔥. Just add `kw_only=True` - a small change that makes your code more readable and safer. No more guessing what positional values mean or accidentally swapping arguments. Simple example below ->
Tweet media one
1
1
12
@KhuyenTran16
Khuyen Tran
1 year
You can use #Python dataclasses with Python match statements to create cleaner and more readable code. This approach can be particularly useful when setting conditions based on multiple attributes of a class. ⭐️ Bookmark this post: 
Tweet media one
5
32
160
@mirascope_ai
Mirascope
3 months
mirascope v2 interface is coming along nicely, response format will now enable dataclasses, pydantic, cattrs, and more so you have flexibility (all type safe too)
Tweet media one
1
0
8
@testdrivenio
TestDriven.io
11 months
Python tip:. Even though dataclasses require type hints for attributes, Python doesn’t enforce these types at runtime. Type hints are for static analysis and documentation, not for restricting types during execution 👇
Tweet media one
1
7
40
@KhuyenTran16
Khuyen Tran
1 year
Dataclasses require manual implementation of validation. On the other hand, @pydantic offers built-in validation that automatically validates data and provides informative error messages. This makes Pydantic particularly useful when working with data from external sources.
Tweet media one
1
20
120
@bbelderbos
Bob Belderbos
1 year
The #Python dataclasses module helps you reduce boilerplate code when creating classes. 💡. It automatically adds special methods like `__init__` and `__repr__` 🐍 😍 📈
Tweet media one
2
4
26
@testdrivenio
TestDriven.io
10 months
Python tip:. You can convert "dataclass" instances to tuples or dictionaries using "dataclasses.astuple()" and "asdict()". Example 👇
Tweet media one
2
8
40
@soumendrak_
Soumendra Kumar Sahoo
11 months
attrs library in Python programming can help in boilerplate class definitions and validation; a kind of alternative for dataclasses and pydantic.
Tweet media one
1
0
0
@KhuyenTran16
Khuyen Tran
8 months
In #Python, using mutable default values in class definitions can cause unexpected behavior. This is because all instances share the same mutable object. To avoid this issue, use the default_factory parameter in dataclasses, which creates a new object for each instance.
Tweet media one
2
16
85
@driscollis
Mike Driscoll
1 year
I asked Claude AI to give me some examples of dataclasses in #Python. The following is an "example of a frozen dataclass". What's wrong with this code?
Tweet media one
3
2
25
@Siro_artemis
山猫シロ🐾少し低浮上
5 months
新しく記事を投稿しました!.PythonのDataClasses入門:簡潔で強力なクラス設計の活用例4選 .
0
4
43
@bbelderbos
Bob Belderbos
1 year
As you probably know #Python dataclasses automate object construction, so you don't need to write an `__init__` method. 🎉. But what if you do want to do some extra initialization?.Use the `__post_init__` method. 📈. Of course, when this gets involved consider using Pydantic
Tweet media one
1
12
68
@eduardo_gpg
Eduardo Ismael..
10 months
Another Python Tip. Es posible crear objetos inmutables a partir de Dataclasses. 🐍.
Tweet media one
0
1
14
@KhuyenTran16
Khuyen Tran
4 months
Manually managing nested data structures using dictionaries can be error-prone and complex. #Python's dataclasses module simplifies this by offering a clean, type-safe way to define structured objects. 📘 Full code:
Tweet media one
2
13
64
@DevAsService
Nuno Bispo (aka Developer Service)
1 year
🚀 New Blog Post Alert! 📄. Discover how Python's Data Classes simplify object-oriented programming!. From reducing boilerplate code to enhancing readability, learn how to make your coding life easier. 🐍💻. Link below 👇. #Python #DataClasses #OOP #ProgrammingTips #CodeBetter
Tweet media one
1
0
1
@KhuyenTran16
Khuyen Tran
6 months
Having multiple #Python function parameters can make code hard to maintain and prone to errors. Dataclasses simplify this by grouping related #Data into simple data structures, making the code more readable and maintainable. 📘 Full code:
Tweet media one
2
5
43
@DevAsService
Nuno Bispo (aka Developer Service)
11 months
✨ Python Dataclasses Tip. Use field(default_factory=. ) for mutable default values like lists or dicts! 🧑‍💻 . It ensures each instance has its own list. #Python #CodingTips #PythonTricks
Tweet media one
0
0
1