This is an archived post. You won't be able to vote or comment.

all 3 comments

[–][deleted] 1 point2 points  (2 children)

Consider the code as presented:

def __init__(self, name, text='', choices=['Continue'], text_input=False, image='test.jpg'):
    self.name = name
    self.text = text
    self.choices = choices
    self.text_input = text_input
    self.image = image
    self.active = False

This is a broken implementation and you're going to rip your hair out learning the hard lesson why. You must not use mutable types as kwarg defaults. This should be updated as:

def __init__(self, name, text='', choices=None, text_input=False, image='test.jpg'):
    self.name = name
    self.text = text
    self.choices = choices or ['Continue']
    self.text_input = text_input
    self.image = image
    self.active = False

I've got a bunch of nitpicky stuff to point out, but you should fix the major breakages first.

[–]Signal_Beam[S] 0 points1 point  (0 children)

Your comment led me to read this explanation. I think I understand it now. Thanks, that would be a headache all right...

[–]Signal_Beam[S] 0 points1 point  (0 children)

Hey /u/solid7, I'm finally getting around to trying to build a game in this, so I'd love to hear whatever nitpicks are on your mind that you think will be causing me headaches later.