0

I’m seeking a term and possibly the code behind what would help me implement that term in Python.

I have been working on a text-based Python journaling application. When I want to review my journal from the command-line shell, it prints out a series of logs like this:

Log_1”...” Log_2”...” Log_3”...”

The problem is, there are a lot of logs under a lot of different dates, so the whole journal looks dense, cluttered, and messy.

I’m not a writer or a language arts expert(I barely use MS-Word), but what I want is to create a one line space between the print of each log:

Log_1”...”

Log_2”...”

Log_3”...”

I don’t know what that space in between each log would be called, so it made it impractical to just do some google research.

What would the space be called? And is they’re a specific code that could be passed through print() which would create the output of that space? Thank you.

6
  • I might be wrong, but is not "linebreak" what are you asking for? Take a look here
    – Laiv
    Commented Jan 13, 2018 at 19:47
  • @Laiv No, that’s the ANSI escape sequence ‘\n’ , That puts each string on it’s own line. I’m already using that. I need each code on it on line(‘\n’), plus a space between each string. That’s the missing part.
    – Iam Pyre
    Commented Jan 13, 2018 at 20:08
  • 3
    But... Isn't what you want just printing another empty line after each log, in effect printing \n\n where you would otherwise print just \n ?
    – user285148
    Commented Jan 13, 2018 at 21:37
  • @user8734617 hmmm, intriguing. Let me test that...
    – Iam Pyre
    Commented Jan 13, 2018 at 22:11
  • @user8734617 Thanks a lot. It works. I’m just now learning the fundamentals of Python, so it makes it hard to just experiment with stuff like that. I guess after I learn the basics it will be easier to just experiment with code.
    – Iam Pyre
    Commented Jan 13, 2018 at 22:33

2 Answers 2

3

There are a number of terms that might be what you're looking for. It's hard to tell from your description, but here are some suggestions what to search for:

  • Leading - AKA Line Spacing - This controls the spacing between lines of text. It gets its name from the fact that they used to use strips of lead between the lines of text on a printing press to change it.
  • Sentence Spacing is the space between sentences. Probably not what you're looking for but might be useful.
  • Kerning is the spacing between characters of type.
  • Reglets were used at one time to control spacing between paragraphs. I've not seen this term used in computer typography, but it's possible that it's used somewhere. Usually, I see it referred to paragraph spacing.
  • Slugs - similar to reglets in that they are pieces of metal used to separate paragraphs or other things in type.
1
  • Leading, AKA line spacing, sounds the most accurate. Going to Google It in a bit. Thanks for the feedback.
    – Iam Pyre
    Commented Jan 13, 2018 at 21:17
1

For reasons beyond my "rookie-python level" understanding, the example that user8734617 gave me, which described passing '\n\n' escape sequence through the print function along with the dictionary(my log) object, didn't work the same between the python IDLE and the Ubuntu terminal shell.

My Logs are values stored in dictionaries. I use the the "for loop" to print them out in the form of a journal in the command-line shell:

For Logs in Today:
    print(Logs,Today[Logs])

>>>'Log_1','Today was a good day.'
   'Log_2','No more cake for me.'
   'Log_3','Done with my Algebra.'

In Python IDLE, I simply only had to pass the escape sequence: '\n\n' , through the same print() function to get the output that I wanted, which is:

>>>'Log_1','Today was a good day.'

   'Log_2','No more cake for me.'

   'Log_3','Done with my Algebra.'

When I ran the same code at terminal, it just added '\n\n' as another string to be output, it didn't actually escape anything. After trial and error and testing, I realized what I needed(at least this is what worked) is another print() function added to the "for loop":

>>>For Logs in Today:
    print(Logs,Today[Logs])
    print('\n')
>>>'Log_1','Today was a good day.'

   'Log_2','No more cake for me.'

   'Log_3','Done with my Algebra.'

This is what worked at the terminal for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.