Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Convert input to upper case on screen as it is typed Date: Thu, 14 Apr 2016 13:25:14 +1000 Lines: 31 Message-ID: References: <85oa9cyiqt.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de asRQ8+H61vD2dBYKCwUe1gcthNV/zHFhdmuXnG8G9fEg== Cancel-Lock: sha1:T/wRKqL7dkp71VlaENHU04/0rZk= Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'resulting': 0.04; 'emulate': 0.07; "ain't": 0.09; 'input,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'system;': 0.09; 'typed': 0.09; 'python': 0.10; 'translate': 0.15; 'lower-case': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:Convert': 0.16; 'subject:case': 0.16; 'subject:screen': 0.16; 'library,': 0.18; 'typing': 0.18; 'input': 0.18; 'keyboard': 0.22; "user's": 0.22; 'appears': 0.23; "python's": 0.23; 'header :User-Agent:1': 0.26; "doesn't": 0.26; 'appear': 0.26; 'command': 0.26; 'header:X-Complaints-To:1': 0.26; 'interface': 0.29; 'readline': 0.29; 'character': 0.29; 'convert': 0.29; 'especially': 0.32; 'lock': 0.33; 'stream': 0.33; 'case,': 0.34; 'running': 0.34; 'could': 0.35; 'text': 0.35; 'done': 0.35; 'something': 0.35; 'should': 0.36; '(i.e.': 0.36; 'to:addr:python- list': 0.36; 'display': 0.37; 'received:org': 0.37; 'available.': 0.37; 'things': 0.38; 'someone': 0.38; 'to:addr:python.org': 0.40; 'some': 0.40; 'ever': 0.60; 'show': 0.62; 'real': 0.62; 'making': 0.62; 'more': 0.63; 'else.': 0.66; 'letters': 0.67; 'u.s.': 0.69; '8bit%:21': 0.70; 'upper': 0.76; '_o__)': 0.84; 'forced': 0.84; 'journalist': 0.84; 'received:125': 0.84; 'visually': 0.84; 'trouble.': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <85oa9cyiqt.fsf@benfinney.id.au> Xref: csiph.com comp.lang.python:106970 How can my Python program convert the user's keyboard input to upper case, as though the user has CAPS LOCK enabled? I want to emulate a program running on a computer which doesn't have any lower-case letters (i.e. a character set more limited than ASCII). The text input, typed interactively by the user at the keyboard, should be forced to upper case in real time as though that's what the user typed. The command line interface could use Python's standard ‘cmd’ library, or something else. The conversion could be done by a custom input stream, or some other way. I am not interested in completely re-implementing the character-by-character input system; for example, I would like to continue making use of readline if it is available. I only want to translate the resulting stream as it appears visually and as it comes into the program. Especially important is that the interface should appear visibly indistinguishable from someone actually typing upper case text; the display should only ever show the user's input as the upper case text the program will process. -- \ “It ain't so much the things we don't know that get us in | `\ trouble. It's the things we know that ain't so.” —Artemus Ward | _o__) (1834–1867), U.S. journalist | Ben Finney