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?
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.
go to
idle -> preferences -> General -> default source encoding -> Locale-defined
Copy-Paste it from notepad.
or
Use command line python shell.
In IDLE, it worked with alt (option) + i.
Everyone i have an excellent solution to this problem.
Go to "Terminal":
Write
Python
Now it works because it's like using IDLE just in terminal and in terminal the backslash will work perfectly fine.
Related
I wrote,
print('C:\docs\rohit')
>>> C:\docsohit
You see rohit is my name but in result, I got docssohit
well basically it moves a sentence toward left but in my case specifically in IDLE it is
giving something else.
IDLE 3.8.0
Python IDLE does not properly handle control charcaters like \r,b etc.. Use Python console interpreter (python.exe,python3.exe) instead.
Use Visual Studio and install the python addons instead.
I am writing some code in a standard python 3.8 shell and I want to print('\a') which plays a ding sound on your computer. This works in a thonny python shell but will not work in any other python shell. Does anyone know why?
Printing '\a' is not supported by IDLE. (I think that '\r' and '\b' also do not work properly.)
I wrote the code mentioned in the example section of this page in the shell of IDLE, and it didn't execute and returned "SyntaxError: multiple statements found while compiling a single statement". What is wrong with it?
I have used pyDes some time ago (Python 2.7, Windows XP) and this worked fine for me.
Which Python are you using, and which is your OS?
IMHO, your syntax error is about a few indentation problems == missed tabs\spaces.
Check spaces and tabs in your code, rewrite code manually
I used IDLE 2.7.5+ and the code produced encrypted text and ran just fine. IDLE 3.3.2+ does not work with pyDes for some reason, at least on my OS: Ubuntu Linux.
I am using Python 2.7.3 on OS X 10.8.3, installed with MacPorts. If I hit command + c or command + x on content in IDLE, I can paste it with command + v into other apps. However, I cannot use command + v to paste into IDLE itself, either from other apps or from within IDLE.
If I highlight content in IDLE, a right-click on the mouse will duplicate (i.e. paste) that content. This is sort of a workaround, but it is annoying not to be able to paste URL's or code from outside of IDLE.
Make sure that you have the cursor more than one space after the last >>>. It won't paste unless you do.
The cmd+C and cmd+V commands weren't working for me either, so I removed them (and macports) and then installed python from the python.org website. I only needed numpy and matplotlib, so I installed those from their sources and it works.
It isn't a solution, but the broken hotkeys seem to have something to do with x11 (https://mail.python.org/pipermail/python-list/2010-January/563387.html). I installed XQuartz(http://xquartz.macosforge.org/landing/) and it still didn't help, so I just removed everything.
I am writing a Python script on Windows, that needs to work on a Red Hat Linux machine. On Windows,
os.path.abspath(os.curdir)
returns something like
C:\Users\Me\...\CurrentDirectory
without a trailing \ .
I'm unable to run it on Linux, but to my knowledge it would be more like
/home/Me/.../CurrentDirectory
with the slashes going the other way, and I'm uncertain about a trailing / . First of all, is there one? Secondly, how do I deal with this issue? The script doesn't have to work on both Windows and Linux, just Linux, in the end. Though I can only test it on Windows :(
It shouldn't matter if you use os.path.join()
See:
Python os.path.join on Windows
Why doesn't os.path.join() work in this case?
The behavior would be more or less the same across the OS. Instead of using \ or / use
os.sep
inside your code. Do not try to hardcode anything