Python Forum
Create class instances from list of strings
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create class instances from list of strings
#2
I would put them in a dictionary:

words = {word': Word() for word in somewords}
Getting the attributes in is another question, but you could probably make them parameters to __init__, and then load them in while creating the dict.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: Create class instances from list of strings - by ichabod801 - Sep-18-2017, 06:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Create a new subclass in a Python extension based on an existing class voidtrance 6 1,557 Mar-25-2025, 06:37 PM
Last Post: voidtrance
  How does this code create a class? Pedroski55 6 2,256 Apr-21-2024, 06:15 AM
Last Post: Gribouillis
  How to read module/class from list of strings? popular_dog 1 1,396 Oct-04-2023, 03:08 PM
Last Post: deanhystad
  Trying to understand strings and lists of strings Konstantin23 2 1,887 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  problem in using int() with a list of strings akbarza 4 1,970 Jul-19-2023, 06:46 PM
Last Post: deanhystad
Question [solved] Classes, assign an attributes to a class not to instances.. SpongeB0B 4 2,084 May-20-2023, 04:08 PM
Last Post: SpongeB0B
  Delete strings from a list to create a new only number list Dvdscot 8 3,532 May-01-2023, 09:06 PM
Last Post: deanhystad
  Help with Logical error processing List of strings dmc8300 3 1,995 Nov-27-2022, 04:10 PM
Last Post: Larz60+
  [split] why can't i create a list of numbers (ints) with random.randrange() astral_travel 7 2,990 Oct-23-2022, 11:13 PM
Last Post: Pedroski55
  Splitting strings in list of strings jesse68 3 2,695 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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