Python Forum
Init an indefinite number of class
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Init an indefinite number of class
#1
Hello world,
I need your help for my new game project.
I want to use x(the number of player) time my class Player.
I think do that but it's not optimum.

from MyClass import Player
x = int(input("Number of player: "))

for i in range(1, x+1):
    exec(f"Player{i} = Player()")
Except that I need to do this for each round of the game.
Can you recommend something better?
Thank you in advance.
Reply


Messages In This Thread
Init an indefinite number of class - by MathisDELAGE - Feb-18-2022, 01:20 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Which GUI can have indefinite loop ? jst 20 2,074 Nov-16-2023, 10:23 PM
Last Post: jst
  PyRun_SimpleFile calling multiprocessing Python Class cause endless init loop Xeno 2 1,131 Sep-19-2022, 02:32 AM
Last Post: Xeno
  Basic Inheritance, Why Use init udinjelek 5 2,275 Sep-29-2021, 06:03 PM
Last Post: deanhystad
  Indefinite loop ( I think ) marsh20 2 2,006 Aug-20-2020, 12:33 PM
Last Post: deanhystad
  Error: How to to close and restart your shell after running 'conda init' angelica 3 10,389 May-27-2020, 10:00 AM
Last Post: snippsat
  Is it mandatory to call superclass init inside the class init? psolar 3 6,252 Feb-14-2020, 09:16 PM
Last Post: wavic
  indefinite loop Johnygo 3 2,212 Jul-03-2019, 12:53 PM
Last Post: Johnygo
  init vs_init_ while defining method/function? hsunteik 1 3,699 Dec-24-2016, 08:27 AM
Last Post: micseydel

Forum Jump:

User Panel Messages

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