How To Use: "@dataclass" In Python (Tutorial 2023)

Поділитися
Вставка
  • Опубліковано 16 лют 2023
  • Here's a quick guide on how you can use dataclasses in Python, and how they help us avoid a lot of boilerplate code.
    ▶ Become job-ready with Python:
    www.indently.io
    ▶ Follow me on Instagram:
    / indentlyreels

КОМЕНТАРІ • 25

  • @thepackbot
    @thepackbot 7 місяців тому +5

    That tidbit about "variables with default values must come after the ones without them", just explained a big problem I was having. Thank you!

  • @FrocketGaming
    @FrocketGaming 26 днів тому

    Thanks for this. As I was watching and working on a selenium web scraping script I realized I could make a config dataclass to store all the css_selectors / xpaths I need for this script!

  • @davidl3383
    @davidl3383 Рік тому +4

    Thank you. Very clear like your udemy couse ;)

  • @adhd_arti
    @adhd_arti Рік тому

    Cool. Thanks!

  • @user-wb6ls4zt4q
    @user-wb6ls4zt4q 3 місяці тому +1

    good

  • @developer_anonymous
    @developer_anonymous 10 місяців тому +7

    'banana.calories = 69, i mean, 60' 😂

  • @enricoroselino7557
    @enricoroselino7557 8 місяців тому +1

    bob job nice

  • @chromery
    @chromery 7 місяців тому

    Great video as always! Have you by any chance made a video about Pydantic (couldn't find it), or are you maybe planning to?

  • @velicihanates3288
    @velicihanates3288 Рік тому +15

    You could have used two asterix operators to insert json in your person class
    'bob = Person(**json)'

    • @Indently
      @Indently  Рік тому +6

      Only if your dataclass fits PERFECTLY the data from the JSON, otherwise it will throw an error.

    • @velicihanates3288
      @velicihanates3288 Рік тому

      @@Indently thanks for telling, I really enjoy your python tutorials!

    • @thepackbot
      @thepackbot 7 місяців тому

      that's called unpacking.

  • @user-of9dq5dl2x
    @user-of9dq5dl2x 3 місяці тому

    your explaination is very helpful for understanding the question 'why we need to do that ', and i like your explaination for reading a json file to an object. Thank you very much for this good video.

  • @kamurashev
    @kamurashev Рік тому +3

    Nice! Named tuple vs dataclass for the next video?

  • @NoidoDev
    @NoidoDev 8 місяців тому

    Is it better to use that for data or some dict? For example, It seem that I won't be able to get "keywords".
    Also, there's a difference between __slots__ and slots=True, which is that you can use default value with the new method.

  • @forethiocodingstaff
    @forethiocodingstaff Рік тому

    Young, energetic python developer

  • @user-xw5hb4yx5u
    @user-xw5hb4yx5u 11 місяців тому

    Do u have a course… or mentoring program

    • @Indently
      @Indently  11 місяців тому

      I have a couple of courses at: indently.io

  • @lostsoul8634
    @lostsoul8634 Рік тому +5

    I'm learning python... bob= Person(**json) is better?

  • @jeyosman1
    @jeyosman1 2 місяці тому

    I just wanted to take a moment to express my sincere appreciation for your exceptional explanations and the engaging speed at which you communicate. Your clarity and enthusiasm truly stand out, making learning from you an absolute pleasure. Thank you for your dedication and talent-I genuinely admire the way you convey information

  • @DrDeuteron
    @DrDeuteron 10 місяців тому

    Don't forget the dataclasses.Field object...can be very useful when dealing with telemetry.
    There's also the "astuple" method that is attached to the class.

  • @betapacket
    @betapacket Рік тому

    5th

  • @Timmie_Tudor
    @Timmie_Tudor Рік тому

    Why are you teaching people how to use me?

    • @Indently
      @Indently  Рік тому

      Because you're great and deserve to be treated with respect.