Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a solo \ at end of comment
#1
what happens if there is a solo backslash at the end of a line in a comment?
   x = 92 # the power char is a \
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
Nothing everything after # is ignored.
If take a deeper look tokenize.py line 113 114.
So can do a test.
>>> import re
>>> 
>>> s = 'Hello World'
>>> r = re.search(r'#[^\r\n]*', s) 
>>> repr(r)
'None'

>>> s = 'Hello# World'
>>> s = 'Hello# World'
>>> r = re.search(r'#[^\r\n]*', s)
>>> r
<re.Match object; span=(5, 12), match='# World'>
>>> r.group()
'# World'

# No matter where put # the rest will match
>>> s = 'Hello W#orld'
>>> r = re.search(r'#[^\r\n]*', s)
>>> r.group()
'#orld'
So line 113 regex Comment = r'#[^\r\n]*',match all after # to carriage return or new line.
line 114 give a hint what Tokenization should do with it Ignore.
Reply
#3
that code block won't scroll for me. so i can't see 113 or 114. oh wait, your 1 key must be bouncy.

i was wondering if the \ at the end of the line would continue that line onto the next.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to add multi-line comment section? Winfried 1 193 Mar-24-2024, 04:34 PM
Last Post: deanhystad
Question remove all comment ? SpongeB0B 7 1,317 Oct-27-2023, 05:40 PM
Last Post: deanhystad
  Regular Expression search to comment lines of code Gman2233 5 1,659 Sep-08-2022, 06:57 AM
Last Post: ndc85430
  Block comment in Intellij kam_uk 2 2,281 Nov-15-2020, 05:22 PM
Last Post: kam_uk
  Python 3 Elementtree and Comment First gw1500se 3 3,731 May-25-2020, 09:02 PM
Last Post: gw1500se
  Youtube Comment bot mateusz135 4 65,719 Mar-14-2020, 04:18 PM
Last Post: buran
  pdb says "SyntaxError: unexpected EOF" on comment pwannh 1 3,062 Nov-29-2018, 04:17 PM
Last Post: nilamo
  Help extracting comment data from multiple zip files SoulsKeeper 10 6,122 Sep-10-2018, 10:33 AM
Last Post: SoulsKeeper
  python crontab remove_all(comment="Minute*") vvarrior 1 2,768 Aug-06-2018, 12:39 AM
Last Post: Larz60+
  comment indentations Skaperen 12 9,091 Jan-29-2017, 06:56 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020