Re: I want to lirn pithon but pithon doesn't want me to do so
You could, but you would be breaking multiple conventions and locking yourself out of passing in parameters to your constructor, i.e:
class Player:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
#Insert some code here
class BadPlayer: x = 0 y = 0 z = 0 #Other stuff
The first approach is clearly more flexible, you can spawn your player anywhere, while the second option forces you to create the object and then manually assign values to it, i.e:
my_player = Player(0, 0, 10) #Good, less to read and cleaner
my_bad_player = BadPlayer()
my_bad_player.x = 0
my_bad_player.y = 0
my_bad_player.z = 0
Also, you are losing the ability to ensure that the passed in values are valid by removing the constructor and hard-coding things.
So, short answer: Can you do it? Yes, you can. Should you? Absolutely not.
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector