Pythonインタプリタ内で日本語入力が使えない件

ターミナルなどでも「かな」キー押下で日本語入力が使えるが、
Python インタプリタでは動作しない。
解決:Mac OSXのPythonのインタプリタで日本語入力する方法 - haya14busa解決:Mac OSXのPythonインタプリタで日本語入力する方法
で紹介されていた方法を使って、解決する。

readline / GNU readlineの問題ということで、.inputrcを探す。

まずは、LaunchPadからターミナルを起動。

その他を選択

ターミナルを選択

ターミナルが起動

当然、まだ.inputrcは作られていない模様。

vi .inputrc

する。


kanji-code utf-8

# Enable 8bit input
set meta-flag on
set input-meta on

# Turns off 8th bit stripping
set convert-meta off

# Keep the 8th bit for display
set output-meta on

set enable-keypad on

内容はいまいち分からないので、そのままコピーさせていただきました。
あとで調べよう。


Last login: Sat Jan 14 19:05:15 on ttys000
YamaguchiTaro-no-MacBook-Pro:~ yamaguchitaro$ python
Python 3.5.2 |Anaconda 4.2.0 (x86_64)| (default, Jul  2 2016, 17:52:12) 
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a=0 #日本語でのコメント
>>> print(a + "これはテストです")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>> print("これはテストです")
これはテストです
>>> 

かなキーで日本語出すことに成功。
これで一々、別アプリケーションで入力したものを、コピペ貼り付けしなくてすみます。