Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between logical line and physical line in python

I was reading and i got these two terms and i am confused as in logical line it says "The end of a logical line is represented by the token NEWLINE". Newline means go to the next line which eventually ends the line.

And in physical line its written "A physical line is a sequence of characters terminated by an end-of-line sequence". so the same thing happens when we use newline with logical line. so what is the difference?

the link is 'https://docs.python.org/3.3/reference/lexical_analysis.html#logical-lines'

like image 246
Mayank Sharma Avatar asked Apr 28 '26 08:04

Mayank Sharma


1 Answers

This is from the Python documentation regarding lexical analysis.

Here is one logical and physical line:

my_list = [1, 2, 3, 4]

Here is one logical line on two physical lines:

my_list = [1, 2,
           3, 4]
like image 173
TigerhawkT3 Avatar answered Apr 29 '26 21:04

TigerhawkT3



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!