python-idle

Terminating idle mysql connections

做~自己de王妃 提交于 2019-11-26 18:03:44
问题 I see a lot of connections are open and remain idle for a long time, say 5 minutes. Is there any solution to terminate / close it from server without restarting the mysql service? I am maintaining a legacy PHP system and can not close the connections those are established to execute the query. Should I reduce the timeout values in my.cnf file those defaults to 8 hours? # default 28800 seconds interactive_timeout=60 wait_timeout=60 回答1: Manual cleanup: You can KILL the processid. mysql> show

When running a python script in IDLE, is there a way to pass in command line arguments (args)?

百般思念 提交于 2019-11-26 15:35:21
问题 I'm testing some python code that parses command line input. Is there a way to pass this input in through IDLE? Currently I'm saving in the IDLE editor and running from a command prompt. I'm running Windows. 回答1: It doesn't seem like IDLE provides a way to do this through the GUI, but you could do something like: idle.py -r scriptname.py arg1 arg2 arg3 You can also set sys.argv manually, like: try: __file__ except: sys.argv = [sys.argv[0], 'argument1', 'argument2', 'argument2'] (Credit http:/

Any way to clear python's IDLE window?

▼魔方 西西 提交于 2019-11-26 14:58:44
I know there's a similar topic about python console, but I do not know if they are the same. I tried system("clear") and it didn't work here. How do I clear python's IDLE window? The "cls" and "clear" are commands which will clear a terminal (ie a DOS prompt, or terminal window). From your screenshot, you are using the shell within IDLE, which won't be affected by such things. Unfortunately, I don't think there is a way to clear the screen in IDLE. The best you could do is to scroll the screen down lots of lines, eg: print "\n" * 100 Though you could put this in a function: def cls(): print "

Python: Why is IDLE so slow?

浪子不回头ぞ 提交于 2019-11-26 14:27:13
问题 IDLE is my favorite Python editor. It offers very nice and intuitive Python shell which is extremely useful for unit-testing and debugging, and a neat debugger. However, code executed under IDLE is insanely slow. By insanely I mean 3 orders of magnitude slow: bash time echo "for i in range(10000): print 'x'," | python Takes 0.052s, IDLE import datetime start=datetime.datetime.now() for i in range(10000): print 'x', end=datetime.datetime.now() print end-start Takes: >>> 0:01:44.853951 Which is

interactive shell debugging with pycharm

微笑、不失礼 提交于 2019-11-26 11:55:36
问题 I am new to PyCharm. I have been using IDLE for a long time. It is very convenient to use Python objects after script execution in IDLE. Is there any way to use script objects after its execution with interactive python shell using PyCharm? For example, we have a \'test\' project with one file \'test.py\': a = \'123\' print a after execution we can get the result: 123 Process finished with exit code 0 How can I use string \'a\' with interactive shell? 回答1: Built-in python shell for current

How to run a python script from IDLE interactive shell?

随声附和 提交于 2019-11-26 10:09:27
问题 How do I run a python script from within the IDLE interactive shell? The following throws an error: >>> python helloworld.py SyntaxError: invalid syntax 回答1: Python2 Built-in function: execfile execfile('helloworld.py') It normally cannot be called with arguments. But here's a workaround: import sys sys.argv = ['helloworld.py', 'arg'] # argv[0] should still be the script name execfile('helloworld.py') Python3 : alternative to exefile: exec(open('helloworld.py').read()) See https:/

IDLE warns against an old TCL version even though I've installed a newer version

百般思念 提交于 2019-11-26 08:33:26
问题 I have installed ActiveTcl8.6.1.1.297588-macosx10.5-i386-x86_64-threaded on my OS X 10.9.1 . However, when I launch IDLE by running idle3 from the terminal, the following warning shows in the IDLE window: Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 16 2013, 23:39:35) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type \"copyright\", \"credits\" or \"license()\" for more information. >>> WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable. Visit http://www.python.org/download/mac

Can multiprocessing Process class be run from IDLE

空扰寡人 提交于 2019-11-26 07:49:02
问题 A basic example of multiprocessing Process class runs when executed from file, but not from IDLE. Why is that and can it be done? from multiprocessing import Process def f(name): print(\'hello\', name) p = Process(target=f, args=(\'bob\',)) p.start() p.join() 回答1: Yes. The following works in that function f is run in a separate (third) process. from multiprocessing import Process def f(name): print('hello', name) if __name__ == '__main__': p = Process(target=f, args=('bob',)) p.start() p.join

Any way to clear python's IDLE window?

旧巷老猫 提交于 2019-11-26 03:48:35
问题 I know there\'s a similar topic about python console, but I do not know if they are the same. I tried system(\"clear\") and it didn\'t work here. How do I clear python\'s IDLE window? 回答1: The "cls" and "clear" are commands which will clear a terminal (ie a DOS prompt, or terminal window). From your screenshot, you are using the shell within IDLE, which won't be affected by such things. Unfortunately, I don't think there is a way to clear the screen in IDLE. The best you could do is to scroll