Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Re: Convert input to upper case on screen as it is typed Date: Thu, 14 Apr 2016 17:53:20 +1000 Lines: 33 Message-ID: References: <85oa9cyiqt.fsf@benfinney.id.au> <85bn5cy6bz.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 DC647XaUruXNweUYZ7fmTQ8CDRwRHpr9QPpbkFa59M/Q== Cancel-Lock: sha1:SZNnyluYK6B9F4YiodBjSI0G9KA= Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'handler': 0.04; 'attributes': 0.07; 'lines.': 0.07; 'reason,': 0.07; 'exits': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'exception': 0.13; 'appropriate': 0.14; '8bit%:26': 0.16; 'attributes,': 0.16; 'attributes.': 0.16; 'gregory': 0.16; 'investigate': 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; 'tty': 0.16; 'using,': 0.16; 'string': 0.17; 'attribute': 0.18; 'driver': 0.18; 'shell': 0.18; 'input': 0.18; 'module': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'linux': 0.26; 'dan': 0.29; 'mode.': 0.29; 'preserve': 0.29; 'up.': 0.32; 'run': 0.33; '8bit%:25': 0.33; "i'll": 0.33; 'that,': 0.34; 'saved': 0.35; 'something': 0.35; 'but': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'setting': 0.37; 'received:org': 0.37; 'suggestion': 0.37; 'thank': 0.38; 'sure': 0.39; 'does': 0.39; 'along': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'your': 0.60; "you'll": 0.61; 'back': 0.62; "they're": 0.66; '_o__)': 0.84; 'messed': 0.84; 'received:125': 0.84; '\xe2\x80\x9csome': 0.84; 'careful': 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: <85bn5cy6bz.fsf@benfinney.id.au> X-Mailman-Original-References: <85oa9cyiqt.fsf@benfinney.id.au> Xref: csiph.com comp.lang.python:106979 Dan Sommers writes: > I don't know which OS you're using, but if I run "stty olcuc" in my > Linux shell, then the input driver does that for me. Gregory Ewing writes: > You might be able to do something with the termios module > to put the tty driver into the appropriate mode. > > If you do that, you'll have to be careful to set it back > again before the program exits for any reason, otherwise > your shell session will be messed up. Thank you both. Okay, ‘termios.tcgetattr’ will let me preserve the attributes, and with Dan Sommers's suggestion of which attribute to use, I may have a shot at setting the terminal attributes. Then with a top-level exception handler I can clean up by restoring the saved attributes with ‘termios.tcsetattr’. I will investigate along those lines. -- \ “Some people have a problem, and they think “I know, I'll use | `\ Perl!”. Now they have some number of problems but they're not | _o__) sure whether it's a string or an integer.” —Benno Rice, 2011 | Ben Finney