when I run this, while it's called test.pyw, this pops up from PIL import Image
im = Image.open('1.bmp') im.show() [image: Inline image 1] On Wed, May 17, 2017 at 6:51 PM, eryk sun <eryk...@gmail.com> wrote: > On Wed, May 17, 2017 at 10:33 PM, Michael C > <mysecretrobotfact...@gmail.com> wrote: > > On Wed, May 17, 2017 at 3:30 PM, eryk sun <eryk...@gmail.com> wrote: > > > >> You're probably running a .py script that's associated with py.exe or > >> python.exe. These executables create a new console (i.e. an instance > >> of the console host process, conhost.exe), if they don't inherit one > >> from their parent process. The new console defaults to creating a > >> visible window. Change the file extension to .pyw. This file extension > >> should be associated with pyw.exe or pythonw.exe, which will not > >> create a console. > >> > >> FYI, the cmd shell is unrelated to that console window. Windows users > >> often confuse the cmd shell with the console window that it uses. I > >> suppose it's less confusing on Linux. Like cmd, bash will inherit the > >> parent's terminal/console; however, it doesn't automatically spawn a > >> terminal on Linux if the parent doesn't have one. (Getting that > >> behavior on Windows requires the DETACHED_PROCESS creation flag.) > >> Since Windows users typically run cmd.exe to get a command-line shell > >> for running programs, they associate cmd.exe with the console window. > >> It isn't obvious that other programs create consoles without any > >> associated instance of cmd.exe. > > > > Actually, that is the whole script! I didn't get used to have the cmd.exe > > window pop up at all, could it be something I did? > > Changing the script's extension to .pyw didn't prevent the console > from appearing? Or did you not try it? > > Also, to reiterate, the cmd shell doesn't create or own any window, > and unless something really weird is going on, there's no cmd.exe > instance associated with the console window that you're seeing. cmd > can use a console via standard I/O File handles, and usually does, but > not always. It's no different from python.exe, powershell.exe, or any > other console application. Really, there is no such thing as a "cmd > window", "python window", or "PowerShell window". Because these are > long-running shell processes (e.g. Python's REPL), people are inclined > to think in those terms, and that's fine, but would you call it a > "where.exe window", "chcp.com window", "doskey.exe window", > "whoami.exe window", "findstr.exe window"? I think not. It's clear > that these programs simply use the console; they don't own it. Neither > do shells, but in the case of shells and other long-running console > processes, we're loose with language for convenience -- as long as it > doesn't confuse our understanding of how things really work. > _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor