Python Forum
append str to list in dataclass
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
append str to list in dataclass
#4
A dictionary will not save information after the program ends. To do that you need files. Either a file you write yourself, or a file that is maintained by a database.

Dataclasses are just a convenient way for writing classes that mostly store information. By using @datacass you get __str__ and __repr__ methods that return prettier strings than those returned by Object. A dataclass can also alutomatically generate comparison methods (__lt__, __gt__, __eq__, etc) that you can use to compare or sort instances of your class. Other than thata, dataclasses are just like any other class. They are not capable of persistent storage.

You should read about json files.
snippsat likes this post
Reply


Messages In This Thread
append str to list in dataclass - by flash77 - Mar-14-2024, 03:41 PM
RE: append str to list in dataclass - by deanhystad - Mar-14-2024, 03:58 PM
RE: append str to list in dataclass - by flash77 - Mar-14-2024, 04:22 PM
RE: append str to list in dataclass - by deanhystad - Mar-14-2024, 04:41 PM
RE: append str to list in dataclass - by flash77 - Mar-14-2024, 04:56 PM
RE: append str to list in dataclass - by snippsat - Mar-14-2024, 05:25 PM
RE: append str to list in dataclass - by flash77 - Mar-14-2024, 06:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to append integers from file to list? Milan 8 1,542 Mar-11-2023, 10:59 PM
Last Post: DeaD_EyE
  read a text file, find all integers, append to list oldtrafford 12 3,807 Aug-11-2022, 08:23 AM
Last Post: Pedroski55
  Using .append() with list vs dataframe Mark17 7 11,047 Jun-12-2022, 06:54 PM
Last Post: Mark17
  How to append multiple <class 'str'> into a single List ahmedwaqas92 2 2,386 Jan-07-2021, 08:17 AM
Last Post: ahmedwaqas92
  How to append to list a function output? rama27 5 6,865 Aug-24-2020, 10:53 AM
Last Post: DeaD_EyE
  Append list into list within a for loop rama27 2 2,460 Jul-21-2020, 04:49 AM
Last Post: deanhystad
  Append only adding the same list again and again viraj1123 4 2,099 Jun-17-2020, 07:26 AM
Last Post: viraj1123
  Cant Append a word in a line to a list err "str obj has no attribute append Sutsro 2 2,654 Apr-22-2020, 01:01 PM
Last Post: deanhystad
  Problem with append list in loop michaelko03 0 1,715 Feb-16-2020, 07:04 PM
Last Post: michaelko03
  append list to empty array SchroedingersLion 1 2,234 Feb-02-2020, 05:29 PM
Last Post: SchroedingersLion

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020