How do I make backslash (\) work in IDLE?

26,821

Since this problem still persists on OSX 10.8 with python 2.7.5 and 3.3.2 and since this is the first google hit when searching for backslash idle here is a more practical solution instead of copy and pasting: Go to:

idle->preferences->keys

Under Action-Keys replace:

expand-word <Option-Key-Slash>

with something you like for instance:

expand-word <Control-Option-Key-Slash>

This should fix it.

Share:
26,821
Kris
Author by

Kris

Updated on July 09, 2022

Comments

  • Kris
    Kris almost 2 years

    I use a Mac and I use Shift + Alt + / when I want to type a \. I'm trying to learn Python and as you can see \ works fine, but not in IDLE.

    How do I make backslash (\) work in IDLE?

    • user1066101
      user1066101 over 13 years
      "but not in IDLE"? What does that mean? How does \\ fail to work in IDLE? What happens that's incorrect?
    • s.m.
      s.m. over 13 years
      @Kris, maybe it's just me, but I cannot figure out what you want to do with the backslash. Print it out? Or use it as a line break in source code?
    • David Yaw
      David Yaw over 13 years
      I think he's saying that his keyboard doesn't have a backslash key, and the usual keyboard shortcut, Shift-Alt-/, doesn't type a backslash in IDLE.
    • Karl Knechtel
      Karl Knechtel over 13 years
      It's been a while since I used a Mac, but the ones I used all had a backslash key, in the same standard spot that PCs do. If you're missing such a key, it probably has more to do with what country you're from.
    • Kris
      Kris over 13 years
      @sm I should have mentioned it. I use it with \n and \t
    • Kris
      Kris over 13 years
      @S.Lott Thank you! That works. Why didn't I think of that?!
    • user1066101
      user1066101 over 13 years
      @Kris: "That works"? What works? What problem do you have? What happens that's incorrect? I still don't understand the question.
    • Kris
      Kris over 13 years
      @S.Lott , I needed a way to type \ in IDLE. It works on my Mac (when I use shift + alt + / ) but not when I try to do it in IDLE. The solution is to type it somewhere else and then copy and paste it in IDLE.
  • Kris
    Kris over 13 years
    copy and paste, that's it! Thank you.
  • user3188922
    user3188922 almost 8 years
    Thanks! Run into this problem today and your answer fixed it perfectly and super easy