Thursday, 15 January 2015

Slog Week #2

I'm writing this having just had my first lab. The assignment was pretty straightforward in easy except for one speed bump I had. I didn't realize initially that for __init__ you didn't have to type arguments in order to store data. What I mean is that I did not know you could do this :

So I was doing this:


It was initially pretty frustrating until I figured it out because it bothered me that whomever was using my class would not be able to add on to lists, for example, right away. They would have to create them first and then add on which I thought would just be tedious. Needless to say, when I figured that out I was both excited and felt like an idiot. 

Other than that little hiccup the lab went well. I think I got the quiz question right, however I think I could improve on my docstrings. My description was a little long and clunky. 

3 comments:

  1. You also don't need to bring in variables as parameters if you're just going to initialize them in the constructor:

    def __init__ (self):
    self.first = []
    self.second = ''

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Thanks Brian! Yeah I figured that out during my lab last week but forgot to update, but yeah very useful

    ReplyDelete