python-idle

What's the working directory when using IDLE?

≯℡__Kan透↙ 提交于 2019-12-03 02:42:44
问题 So, I'm learning Python and would like to create a simple script to download a file from the internet and then write it to a file. However, I am using IDLE and have no idea what the working directory is in IDLE or how to change it. How can I do file system stuff in IDLE if I don't know the working directory or how to change it? 回答1: You can easily check that yourself using os.getcwd: >>> import os >>> os.getcwd() 'C:\\Program Files\\Python33' That’s on my Windows machine, so it’s probably the

How to remove tab indent from several lines in IDLE?

て烟熏妆下的殇ゞ 提交于 2019-12-03 02:38:47
问题 If you want to indent several lines in Python IDLE you just mark the lines and hit Tab. But what if you want to remove the indent from several lines? Shift+Tab does not work for that in IDLE. 回答1: If you're using IDLE, and the Norwegian keyboard makes Ctrl-[ a problem, you can change the key. Go Options->Configure IDLE. Click the Keys tab. If necessary, click Save as New Custom Key Set. With your custom key set, find "dedent-region" in the list. Click Get New Keys for Selection. etc I tried

How to get the list of all initialized objects and function definitions alive in python?

不羁岁月 提交于 2019-12-03 00:58:11
Say that in the python shell (IDLE) I have defined some classes, functions, variables. Also created objects of the classes. Then I deleted some of the objects and created some others. At a later point in time, how can I get to know what are the currently active objects, variables, and methods definitions active in the memory? Yes. >>> import gc >>> gc.get_objects() Not that you'll find that useful. There is a lot of them. :-) Over 4000 just when you start Python. Possibly a bit more useful is all the variables active locally: >>> locals() And the one active globally: >>> globals() (Note that

PYTHON - Uppercase and Lowercase

♀尐吖头ヾ 提交于 2019-12-02 23:52:54
问题 In my code it is; If 'Laia' in name: But how do I make it so even if they input; LaIa or laiA. No matter what case(upper or lower) it reads as the same thing. 回答1: I would suggest you convert all input to lowercase using the .lower() function, and compare the input with a lowercase string: 'laia' like so name = raw_input('What is the name? ').lower() if name == 'laia': # do stuff 来源: https://stackoverflow.com/questions/24150936/python-uppercase-and-lowercase

mysql connection timeout, inactivity

本小妞迷上赌 提交于 2019-12-02 21:21:01
问题 I have MySQL server installed and I would like it to stop dropping inactive connections. Which option do I need to adjust? The MySQL server is installed on a Windows machine. Thanks 回答1: You are looking for the MySQL wait_timeout variable. SET @@GLOBAL.wait_timeout=2147483 来源: https://stackoverflow.com/questions/9488390/mysql-connection-timeout-inactivity

How to import/open numpy module to IDLE

╄→гoц情女王★ 提交于 2019-12-02 21:14:05
I want to use numpy for a program I have to run and I want to do it in the IDLE IDE. I have installed the numpy binary from online, but when I try running "import numpy" and then some numpy commands in my script, but the python shell returns an error saying Traceback (most recent call last): File "/Users/Admin/Desktop/NumpyTest.py", line 1, in <module> import numpy as np ImportError: No module named numpy I have tried using pip to install numpy, but when I run pip install numpy in the bash shell, it says Requirement already satisfied (use --upgrade to upgrade): numpy in ./anaconda/lib/python2

What's the working directory when using IDLE?

那年仲夏 提交于 2019-12-02 16:18:00
So, I'm learning Python and would like to create a simple script to download a file from the internet and then write it to a file. However, I am using IDLE and have no idea what the working directory is in IDLE or how to change it. How can I do file system stuff in IDLE if I don't know the working directory or how to change it? You can easily check that yourself using os.getcwd : >>> import os >>> os.getcwd() 'C:\\Program Files\\Python33' That’s on my Windows machine, so it’s probably the installation directory of Python itself. You can change that directory at runtime using os.chdir : >>> os

How to remove tab indent from several lines in IDLE?

无人久伴 提交于 2019-12-02 16:12:45
If you want to indent several lines in Python IDLE you just mark the lines and hit Tab. But what if you want to remove the indent from several lines? Shift+Tab does not work for that in IDLE. If you're using IDLE, and the Norwegian keyboard makes Ctrl-[ a problem, you can change the key. Go Options->Configure IDLE. Click the Keys tab. If necessary, click Save as New Custom Key Set. With your custom key set, find "dedent-region" in the list. Click Get New Keys for Selection. etc I tried putting in shift-Tab and that worked nicely. If you're using IDLE, you can use Ctrl+] to indent and Ctrl+[ to

How do I access the command history from IDLE?

为君一笑 提交于 2019-12-02 14:46:30
On bash or Window's Command Prompt, we can press the up arrow on keyboard to get the last command, and edit it, and press ENTER again to see the result. But in Python's IDLE 2.6.5 or 3.1.2, it seems if our statement prints out 25 lines, we need to press the up arrow 25 times to that last command, and press ENTER for it to be copied? Or use the mouse to pinpoint that line and click there, and press ENTER to copy? Is there a faster way? shylent I think you are looking for the history-previous action, which is bound to alt + p by default. You can remap it in Options->Configure IDLE->Keys

PYTHON - Uppercase and Lowercase

岁酱吖の 提交于 2019-12-02 13:43:12
In my code it is; If 'Laia' in name: But how do I make it so even if they input; LaIa or laiA. No matter what case(upper or lower) it reads as the same thing. I would suggest you convert all input to lowercase using the .lower() function, and compare the input with a lowercase string: 'laia' like so name = raw_input('What is the name? ').lower() if name == 'laia': # do stuff 来源: https://stackoverflow.com/questions/24150936/python-uppercase-and-lowercase