try/except block and ctrl-d/EOFError

1.1k Views Asked by At

I'm trying to learn Python. I'm using Windows 10 on a desktop PC.

I initially went through University of Michigan's 'Python for Everyone' on the edx.org platform. For that I used the Atom editor and installed Python from www.python.org Installed version of Python is 3.10.4.

I then uninstalled Python and Atom and installed Anaconda/Spyder. The reason for doing this was that I wanted to make use of the tools from JPL/NASA for calculating and visualizing orbits (as in orbital mechanics; search for 'AWP orbital' on Youtube, you'll see what I wanted to do). I tried initially to install the required libraries, but as I had read in a post on this site, attempting to do this in Windows 10 will probably not work, so the recommendation was to use Anaconda as it comes with literally everything. So after switching to Anaconda, I was able to run the samples that that Youtuber provided in his github, but I didn't understand enough to do anything else with it.

So, having realized that I'm in way over my head, still need to do more basic stuff in Python. I'm 47 so this stuff doesn't come easy to me. No prior programming experience other than messing around with C a bit in uni 20+ years ago to do number crunching.

Sorry for rambling on... in any case, now I'm going through the Harvard CS50 Introduction to Programming with Python on edx.org and I uninstalled Anaconda and went back to Atom and installed Python from python.org like the first time around.

Finally I'm getting to the question. Before installing Anaconda, when I used cmd or the powershell, I could use the ctrl-d to get the EOFError in a try/except block of code, but now when I use either cmd or powershell, ctrl-d just displays ^D but doesn't actually execute the break that I have after my except statement. I tried changing it to ctrl-c and changing the except to KeyboardInterrupt, and that does execute the break, but it seems it doesn't work quite the same way. It would seem that having switched to Anaconda and then back to a basic install from python.org is what caused this ctrl-d to not work anymore, but I don't have a clue as to what I need to do to restore this functionality.

Any ideas?

0

There are 0 best solutions below