November 24, 2014

Week of 11/16/14 - Python Part 11: Classes

     This week I learned a little bit more about classes. Classes seem to be a way of making variables with several attributes. I think that because you have to write a variable to be equal to the class's name with several arguments. For example:
variable = classname(arguments).
     Also, you have to define each class in a weird way. You have to type:
class Classname(object):
    def __init__(self, name) # This is needed to initialize a class, gives it arguments
                             # One of it's arguments has to be self for some reason
                             # This one's arguments are self and name
        self.name = name     # I don't know why this is needed but ok
     Altogether it looks like this:
class Classname(object):
    def __init__(self, name)
         self.name = name

    
Most of the day was spent trying to do html stuff with blogger. I have also discovered the <code> and <pre> tags. I was also changing up past posts to use the <pre> and <code> tags as well.

No comments: