[Tutor] Changing the interpreter prompt symbol from ">>>" to ???

Albert-Jan Roskam sjeik_appie at hotmail.com
Sun Mar 13 04:14:54 EDT 2016



> From: eryksun at gmail.com
> Date: Sun, 13 Mar 2016 01:39:11 -0600
> To: tutor at python.org
> Subject: Re: [Tutor] Changing the interpreter prompt symbol from ">>>" to ???
> 
> On Sat, Mar 12, 2016 at 12:46 AM, boB Stepp <robertvstepp at gmail.com> wrote:
> > I did with the non-printing control character, but not with '\u25ba' !
> >  So I had to go through some contortions after some research to get my
> > Win7 cmd.exe and PowerShell to display the desired prompt using
> 
> The console is hosted by another process named conhost.exe. When
> Python is running in the foreground, the cmd shell is just waiting in
> the background until Python exits.
> 
> > '\u25ba' as the character with utf-8 encoding.  My new
> > pythonstartup.py file (Which PYTHONSTARTUP now points to) follows:
> >
> > #!/usr/bin/env python3
> >
> > import os
> > import sys
> >
> > os.system('chcp 65001')    # cmd.exe and PowerShell require the code
> > page to be changed.
> > sys.ps1 = '\u25ba '  # I remembered to add the additional space.
> 
> chcp.com calls SetConsoleCP (to change the input codepage) and
> SetConsoleOutputCP. You can call these functions via ctypes if you
> need to separately modify the input or output codepages. For example:

I thought that utf-8 (cp65001) is by definition (or by design?) impossible for console output in windows? Aren't there "w" (wide) versions of functions that do accept utf-8? 

Best wishes,
Albert-Jan

 		 	   		  


More information about the Tutor mailing list