Comments

ASnake Documentation

Table Of Contents

Summary:

Comments are messages you leave in the present, to be discovered by you or someone else in the future, to help them understand the functionality or intent of code. It's pretty important. For the most part, ASnake comments work the same as Python comments, except for a few additions.

Comments typically do not affect the functionality of code in any way, except for multi-line strings. They are merely hints for humans.

Syntax # this is a comment:

Once a # is inserted, everything to the right of it becomes a comment, and is thus ignored. The comment ends upon the next line.

# this is a comment
print(2) # this is also a comment
# result: 2
Try this code ➤

Syntax """Multi-line string/comment""":

It is annoying to insert a # on every line for a big comment. Thus multi-line strings can be used in it's place.

However, it is technically a string, and thus can be assigned or operated upon. To complicate matters, when it is inserted at the top of a function it becomes a "doctstring", which can be programmatically read from within the interpreter. Usually this is for automatically generating docs, but it is something to keep in mind. You can read more about it on this Python pep.

''' this is
a multi line
comment.
you can use " instead of ' too.
'''  
variable = """ this is not
a comment, since it is being assigned
to a variable. this is a string! """  
print(variable)
Try this code ➤

ASnake Specific Comment Syntax:

Syntax !#:

In ASnake, a comment can be inlined. Regular comments turn everything to the right into the comment, but in ASnake you can avoid this by specifying the end.

This is done by inserting a ! right before a closing #.

x = 2 + # this is an inline comment !# 2
print x
# result: 4
Try this code ➤

Syntax 💭 💬 "easter egg":

jeffdragon from Discord suggested this as a secret alias 'easter egg' syntax for comments. They suggested that this be kept secret, but I don't care.

Anyway, you can begin your comment with either the 💭 emoji or the 💬 emoji instead of #.

💭 this is a comment
print 12
💬 this is also a comment
# result: 12
Try this code ➤

For those who wanted to use those as variables... I'm sorry.

Scroll to top