OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How can a Python class know what an instance is called?

  • Thread starter Thread starter Michael Savage
  • Start date Start date
M

Michael Savage

Guest
I am trying to make a physics engine using python turtle. I have a class called Entity, which has parameters shape, for either a square or circle. It has a attribute inside __init__() which is called controller which is just a python Turtle

Lets say I create a instance my_square = Entity("square"). How can, upon initialisation, my_square be appended to a list of current entities? I really want to avoid using a name parameter, and then adding that.
<p>I am trying to make a physics engine using python turtle. I have a class called <code>Entity</code>, which has parameters <code>shape</code>, for either a square or circle. It has a attribute inside <code>__init__()</code> which is called <code>controller</code> which is just a python Turtle</p>
<p>Lets say I create a instance
<code>my_square = Entity("square")</code>. How can, upon initialisation, <code>my_square</code> be appended to a list of current entities? I really want to avoid using a <code>name</code> parameter, and then adding that.</p>
 

Latest posts

O
Replies
0
Views
1
OrangeRind
O
D
Replies
0
Views
2
Domantas Giedraitis
D
Top