How do I enter a pound sterling character (£) into the Python interactive shell on Mac OS X?

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?


Asked by: Rubie580 | Posted: 24-09-2021






Answer 1

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.

Answered by: Lucas851 | Posted: 25-10-2021



Answer 2

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.

Answered by: Miranda847 | Posted: 25-10-2021



Answer 3

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

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

Answered by: Madaline645 | Posted: 25-10-2021



Answer 4

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?

Answered by: Lily131 | Posted: 25-10-2021



Answer 5

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?

Answered by: Caroline344 | Posted: 25-10-2021



Similar questions

How to paste Tab character into Python interactive shell

Today, I tried to paste "ip[tab]port" in a interpreter, the result is "ipport". Example: Copy 111.222.3.44 80(using spaces, here, in lieu of tab) from another source, e.g. Notepad, and paste it into the interactive shell. Unfortunately, when I try this, the [tab] doesn't paste, and the result is:111.222.3.4480 I would like to be able to paste the IP & Port with the [tab] s...


python - Interactive console using Pydev in Eclipse?

I'm debugging my Python code in Eclipse using the Pydev plugin. I'm able to open a Pydev console and it gives me two options: "Console for currently active editor" and "Python console". However none of them is useful to inspect current variable status after a breakpoint. For example, the code stopped at a breakpoint and I want to inspect an "action" variable using the console. However my variables are not available...


Can I use IPython in an embedded interactive Python console?

I use the following snippet to drop into a Python shell mid-program. This works fine, but I only get the standard console. Is there a way to do the same but using the IPython shell? import code class EmbeddedConsole(code.InteractiveConsole): def start(self): try: self.interact("Debug console starting...") except: ...


utf 8 - How can I get interactive Python to avoid using readline while allowing utf-8 input?

I use a terminal (9term) that does command-line editing itself - programs that use readline just get in its way. It's fully utf-8 aware. How can I make an interactive python session disable readline while retaining utf-8 input and output? Currently I use: LANG=en_GB.UTF-8 export LANG cat | python -i however this causes sys.stdin.encoding to be None, which implies Ascii (the system ...


Make Emacs use UTF-8 with Python Interactive Mode

When I start Python from Mac OS' Terminal.app, python recognises the encoding as UTF-8: $ python3.0 Python 3.0.1 (r301:69556, May 18 2009, 16:44:01) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.stdout.encoding 'UTF-8' This works the same for python2.5. But inside Emacs,...


shell - How to save a Python interactive session?

I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful bits as often as I would like. Is there a way to save my input into the shell (db connections, variable assignments, little for loops and bits of logic) -- some history of the interactive session? If I use something like


eclipse - Jump into a Python Interactive Session mid-program?

Hey I was wondering... I am using the pydev with eclipse and I'm really enjoying the powerful debugging features, but I was wondering: Is it possible to set a breakpoint in eclipse and jump into the interactive python interpreter during execution? I think that would be pretty handy ;) edit: I want to emphasize that my goal is not to jump into a debugger. pydev/eclip...


command line - Handling exceptions without try block in Python's interactive shell

See the title of this question. I want to play with the exception raised in the last command. _ didn't help me. Is there anything like that?


debugging - Easiest way to pop up interactive Python console?

My application has a Python interpreter embedded in it. However there's currently not any way to inspect anything about Python directly. I'd like to be able to pop up an interactive shell at various points to inspect what's going on in Python. I've found several similar questions which pointed me to code.InteractiveConsole and IPython. However neither of those seem to do anything when I call them - the call appears...


python - Is it possible to pass a variable out of a pdb session into the original interactive session?

I am using pdb to examine a script having called run -d in an ipython session. It would be useful to be able to plot some of the variables but I need them in the main ipython environment in order to do that. So what I am looking for is some way to make a variable available back in the main interactive session after I quit pdb. If you set a variable in the topmost frame it does seem to be there in the...


Interactive python

This question already has answers here:






Still can't find your answer? Check out these communities...



PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python



top