Quote:
|
Originally Posted by Sane
Adding and removing digits from the right would take just as much multiplication/division with strings as from the left.
Adding digit:
self.txt = int(str(self.txt) + str(random.randrange(0,10)))
Removing digit:
self.txt = int(str(self.txt)[0:len(self.txt)-2])
|
Erm... no - if you go from the right you don't need strings - a huge difference in beauty/brevity:
def kill_digit(self):
self.val //= 10
def add_digit(self):
self.val *= 10
self.randomize()
Quote:
|
And why should it matter anyways, if the program really has no point, and digits are generally added and removed from the left. o_O??
|
Because good habits matter when your programs do have a point, and pretty code is generally easier to maintain/improve.
--OH.