python-idle

Python IDLE syntax coloring (highlighting) of print inconsistent?

荒凉一梦 提交于 2019-12-13 22:25:02
问题 Is Python IDLE consistent regarding syntax coloring (highlighting) of print? I tested using IDLE 2.7.2. Sometimes it recognizes as a keyword. Sometimes as built-in ( such as list() or tuple() ). Both of them are, IMHO, correct; so IDLE is inconsistent? Let me know your opinion. KW Added a screenshot 2012 04 01 18:27 KST (April fool's day but the shot is true.) Link to my screenshot How I made this: Second print will be built-in from the beginning. The last(=fourth) print is more tricky. First

bs4: “soup.title.string” doesn't work on IDLE but Terminal

假装没事ソ 提交于 2019-12-13 11:54:15
问题 Mac OS X 10.9 Python 2.7 IDLE BeautifulSoup 4 installed (successfully) I followed BS4 documentation and was practicing some of the functions on IDLE . The following code works and was able to print out title & title.name. from bs4 import BeautifulSoup html = """ <html><head><title>The Dormouse's story</title></head> <body> <p class="title"><b>The Dormouse's story</b></p> <p class="story">Once upon a time there were three little sisters; and their names were <a href="http://example.com/elsie"

Python 2.7.2 IDLE shell not working

微笑、不失礼 提交于 2019-12-13 04:10:09
问题 For some reason the python 2.7.2 IDLE shell is not opening. I get an error that says: "IDLE can't bind to a TCP/IP port, which is necessary to communicate with its Python execution server. This might be because no networking is installed on this computer. Run IDLE with the -n command line switch to start without a subprocess and refer to HELP/IDLE Help 'Running without a subprocess' for further details." It was working fine the day before and I can't think of any changes I have made to the

Blank python IDLE window when opening python file on macOS

大憨熊 提交于 2019-12-13 02:48:21
问题 For some reason, whenever I try to open a python script that has around ~450 lines of code, IDLE's windows simply appears empty and when I try to run it doesn't run anything either... However, if I try to run a smaller program it works for some reason. Does anybody know how I am able to run a python script on my Mac besides IDLE or how to fix the IDLE window being blank whenever I open a file? 回答1: To learn how to run Python Python programs on a Mac, read Chapters 1 and 4 of Python Setup and

Python Shell High CPU Usage

拈花ヽ惹草 提交于 2019-12-13 01:28:51
问题 I have Python 3.4.3 installed on an older laptop (Pentium 4) with Windows XP. It seems that half the time when the Python shell is open, the CPU usage goes up to 12-13%. It is the Python shell itself, not any Python script it may have launched, and not the IDLE text editor. I have yet to figure out the pattern when it goes up and when it does not. CPU usage actually goes to zero when I begin to debug a tkinter based script. The shell window is opened by clicking on IDLE shortcut, if it makes

Find out if a python script is running in IDLE or terminal/command prompt

强颜欢笑 提交于 2019-12-12 10:49:07
问题 Is there a way to find out if the python script is running in the IDLE interpreter or the terminal? Works cross-platform if possible, or if needed a different way for each platform. Work with Python 2 and Python 3 if possible, or if needed a different way for each version. The only way I could think of is checking the processes running for IDLE but I don't know how to do that right. If IDLE is open for another script and my script is running in the terminal, a process check would return true

Delphi idle handler only fires when I move the mouse

拟墨画扇 提交于 2019-12-12 09:55:28
问题 I have an OnIdle handler in my D2006 app. With this code: procedure TMainForm.ApplicationEvents1Idle(Sender: TObject; var Done: Boolean); begin Inc (IdleCalls) ; Sleep (10) ; Done := False ; end ; the app runs smoothly, the idle handler is called 100 times per second, and the CPU usage is next to zero. I then added a TActionList and connected up some controls to actions, coded an Execute and Update handler. procedure TMainForm.ActionNewButtonExecute(Sender: TObject); begin DoNewProject ; end

How to stop Python program execution in IDLE

你。 提交于 2019-12-12 08:30:07
问题 I have a python script that uses plt.show() as it's last instruction. When it runs, IDLE just hangs after the last instruction. I get the image but I don't get the prompt back. On other scripts I typically use ctrl-c to break the program (sometimes doesn't work immediately) but how do I get the prompt back with the plt.show() ? Ctrl-c doesn't work... Are there other ways to stop the program? This is IDLE on Windows, if it makes any difference. 回答1: I have seen this problem with IDLE and

Difference Between Python's IDLE and its command line

早过忘川 提交于 2019-12-12 07:12:14
问题 What are the key differences between Python's IDLE and its command line environment? IDLE looks nicer, of course, and has some kind of GUI... Moreover, is IDLE treated the same as the shell? I mean, the shell is the middle layer between the user and Python's interpreter? Thanks 回答1: They are both the same thing but, IDLE is made to write python code so its better if you can to write on IDLE. You can also try Notepad++ its a pretty good program to write code on. 回答2: I am not sure what you

import urllib3 works in terminal but not on IDLE

守給你的承諾、 提交于 2019-12-12 04:29:50
问题 I am using Mac OSX 10.10.5, and Python version 3.5.2, and IDLE version 3.5.2. I am extremely new to Python, and am trying to use the urllib3 module in IDLE. I have used the following code in the Terminal with success (the number 200 is returned): import urllib3 http = urllib3.PoolManager() r = http.request('GET', 'http://httpbin.org/robots.txt') r.status But the same code does not work in IDLE. In IDLE I get the following error: Traceback (most recent call last): File "/Users/faculty