thiagola92 / learning-interpreters

0 stars 0 forks source link

Add multiline string #2

Open thiagola92 opened 6 months ago

thiagola92 commented 6 months ago

Python way

"""line1
line2
line3"""

Which can be very ugly when inside code blocks

def function():
  string = """line1
line2
line3"""
  print(string)

Concat?

Making every string followed by another string concatenate could be a option but pressing a bunch of time " is annoying

def function():
  string = "maybe"
           "this"
           "way"
  print(string)

Would make a little less annoying them

def function():
  string = "maybe"
           + "this"
           + "way"
  print(string)

String scope

Block writing on open quotes line
Block writing on close quotes
Use closing quotes to know the base indentation, no line should have less than that

def function():
  string = """
      line1
      line2
      line3
  """
  print(string)

Why not using the first line as base? Not sure why not, but would require more logic and thinking