Python Forum
super newbie question: escape character
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
super newbie question: escape character
#1
i'm trying pycharm and idle at the same time, and found a strange situation
print("1 hello")
print("2 hell\n o")
[color=#E74C3C]print("3 hell\r xxx")
print("4 hell\rxxx")
print("5 hell\b o")[/color]
print("6 hell\to")
the result
in pycharm:
Output:
1 hello 2 hell o xxx xxx 5 hel o 6 hell o
in idle:
Output:
1 hello 2 hell o 3 hell xxx 4 hell xxx 5 hell o 6 hell o
why are the difference in line 3, 4 & 5? Huh Huh Huh
Larz60+ write Jan-13-2021, 03:33 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts
Reply
#2
You have different terminal emulators that are probably dealing with the carriage return character \r differently. The program is sending the same characters to stdout, but the terminal rendering is acting on that information in a different way.

The first is treating it as "go back to beginning of the line". So in that case the text afterward overwrites the text written earlier on that line.

The second is treating it as a more normal end of line and not allowing it to overwrite the previous text.

This looks like a program rendering issue, not a python programming issue. You'd have the same thing if you just had a file with that output as contents and had the programs try to display it.
Reply
#3
well, this is all the code, it's something like my third day in Python world
i'm starting from the very beginning.
Reply
#4
(Jan-13-2021, 01:08 AM)bowlofred Wrote: You have different terminal emulators that are probably dealing with the carriage return character \r differently. The program is sending the same characters to stdout, but the terminal rendering is acting on that information in a different way.

The first is treating it as "go back to beginning of the line". So in that case the text afterward overwrites the text written earlier on that line.

The second is treating it as a more normal end of line and not allowing it to overwrite the previous text.

This looks like a program rendering issue, not a python programming issue. You'd have the same thing if you just had a file with that output as contents and had the programs try to display it.

i'm reviewing different on-line videos for starters, and one is using the built-in IDLE, the other PyCharm.
Thanks for the tips, as long as it's not a syntax problem, i'm ok. will worry about the setup later.
Danks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems with super() Hoespilaar 2 234 Apr-10-2024, 10:10 AM
Last Post: Hoespilaar
  super() in class akbarza 1 458 Dec-19-2023, 12:55 PM
Last Post: menator01
  How is pandas modifying all rows in an assignment - python-newbie question markm74 1 703 Nov-28-2023, 10:36 PM
Last Post: deanhystad
  newbie question - can't make code work tronic72 2 694 Oct-22-2023, 09:08 PM
Last Post: tronic72
  Newbie question about switching between files - Python/Pycharm Busby222 3 608 Oct-15-2023, 03:16 PM
Last Post: deanhystad
  How do I handle escape character in parameter arguments in Python? JKR 6 1,162 Sep-12-2023, 03:00 AM
Last Post: Apoed2023
  Newbie.... run for cover. OpenCV question Stevolution2023 2 977 Apr-12-2023, 12:57 PM
Last Post: Stevolution2023
  use of escape character in re.sub and find WJSwan 1 914 Feb-16-2023, 05:19 PM
Last Post: Larz60+
  numpy newbie question bcwilly_ca 4 1,190 Feb-10-2023, 05:55 PM
Last Post: jefsummers
  Escape indentation Frankduc 11 3,082 Jan-31-2022, 02:41 PM
Last Post: Frankduc

Forum Jump:

User Panel Messages

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