views:

967

answers:

5

Update: Thanks for the suggestions guys. After further research, I’ve reformulated the question here: Python/editline on OS X: £ sign seems to be bound to ed-prev-word

On Mac OS X I can’t enter a pound sterling sign (£) into the Python interactive shell.

  • Mac OS X 10.5.5
  • Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
  • European keyboard (£ is shift-3)

When I type “£” (i.e. press shift-3) at an empty Python shell, nothing appears.

If I’ve already typed some characters, e.g.

>>> 1234567890 1234567890 1234567890

... then pressing shift-3 will make the cursor position itself after the most recent space, or the start of the line if there are no spaces left between the cursor and the start of the line.

In a normal bash shell, pressing shift-3 types a “£” as expected.

Any idea how I can type a literal “£” in the Python interactive shell?

+1  A: 

Must be your setup, I can use the £ (Also european keyboard) under IDLE or the python command line just fine. (python 2.5).

edit: I'm using windows, so mayby its a problem with the how python works under the mac OS?

Fire Lancer
+2  A: 

In unicode it is 00A003. With the Unicode escape it would be u'\u00a003'.

Edit: @ Patrick McElhaney said you might need to use 00A3.

Maudite
That didn't work for me, but 00A3 did.
Patrick McElhaney
+1  A: 

I'd imagine that the terminal emulator is eating the keystroke as a control code. Maybe see if it has a config file you can mess around with?

Ryan
+2  A: 

Not the best solution, but you could type:

 pound = u'\u00A3'

Then you have it in a variable you can use in the rest of your session.

Patrick McElhaney
+1  A: 

u'\N{pound sign}'

If you are using ipython, put

execute pound = u'\N{pound sign}'

in your ipythonrc file (in "Section: Python code to execute") this way you will always have "pound" defined as the pound symbol in the interactive shell.

indentation