Curious about comments in 19. Introduction to Classes


I notice that when we reach 19. Introduction to Classes, suddenly the codes all contain things like this:

class Animal(object):
    """Makes cute animals."""

which puzzled me, because we learnt pretty early on that triple quotes were used for multi-line comments, but this is a pretty short comment that barely extends over the entire line.

Quite a minor observation, I know, but one which interests me nonetheless :stuck_out_tongue:



Python doesn't have multi-line comments.
Triple quotes are multi-line strings. Strings and other values that aren't used, get ignored


@ionatan, thanks for the link :slight_smile:

I got the idea that it was a multi-line comment thing from this particular codecademy exercise:



You can use them as comments, the bdfl says so himself. You might want just the text, without leading '# '

Any text editor worth its salt has a way of commenting out lines though. For example, in vim I'd select the lines to comment out and then insert '# '.. or record a macro and repeat it, to comment the next 10 lines I could type: qqI# (esc)jq9@q .. it totally makes sense, I promise.


uh yeah...whatever bdfl and you say :stuck_out_tongue:



Doing my best to indoctrinate you here. Not at all off-topic but learning some myself here.

Well, and then you ask, what if you want to comment lines matching a regex pattern!?

Vim has the answer!
Lets comment all lines that have an 'o' in them!

:g/.*o.*/norm I#

I'm sure that'll save me lots of time, couldn't possibly be unproductive to memorize stuff like that.


I don't mean to dismiss your efforts, but as an ultra beginner your words lead me straight into a towering maze of lalang, leaving me lost and scratching my head regarding everything from vim to regex patterns :cry:

So what I'm gonna do is to come back again one day in the near future and revisit whatever you have said. My current level is simply too low to fully unlock your valuable content :frowning:

So haha, thanks truck-loads anyway!

P.S. saved your comments by favouriting them!


I'm just amusing myself. And letting you know that there's an editor called vim that you probably shouldn't use because it becomes impossible to use anything else afterwards. Huge learning curve, not productive, don't do it. I mean it. No.


Aye aye cap't! :open_mouth: