Python Forum
How to create a varying qty of instances of a Class and name them?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to create a varying qty of instances of a Class and name them?
#1
For a very simple dice game I intend to create a class with attributes of name and score. It is straight forward to create this and also to create objects of player1, player2 and so on. However if I don't know how many player objects I need as the number of players is dynamic, can I make a function which will create and name these player objects?
Reply


Messages In This Thread
How to create a varying qty of instances of a Class and name them? - by KM007 - May-29-2020, 12:15 PM
RE: How to create Objects in Classes - by Yoriz - May-29-2020, 12:20 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How does this code create a class? Pedroski55 6 502 Apr-21-2024, 06:15 AM
Last Post: Gribouillis
Question [solved] Classes, assign an attributes to a class not to instances.. SpongeB0B 4 975 May-20-2023, 04:08 PM
Last Post: SpongeB0B
  Cannot convert the series to <class 'int'> when trying to create new dataframe column Mark17 3 8,597 Jan-20-2022, 05:15 PM
Last Post: deanhystad
  Accessing varying command line arguements Rakshan 3 2,079 Jul-28-2021, 03:18 PM
Last Post: snippsat
  Create Generator in the Class quest 1 2,149 Apr-15-2021, 03:30 PM
Last Post: jefsummers
  How to create and define in one line a 2D list of class objects in Python T2ioTD 1 2,068 Aug-14-2020, 12:37 PM
Last Post: Yoriz
  Class Instances called in the wrong order IanIous 4 2,877 Mar-06-2020, 02:16 PM
Last Post: IanIous
  How to access class variable? instances vs class drSlump 5 3,388 Dec-11-2019, 06:26 PM
Last Post: Gribouillis
  Have two class instances affect one another The_Zookinator 3 2,318 Jun-26-2019, 06:56 PM
Last Post: The_Zookinator
  How I can create reference to member of the class instance? AlekseyPython 8 3,904 Dec-05-2018, 06:24 AM
Last Post: AlekseyPython

Forum Jump:

User Panel Messages

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