python-idle

How to turn on line numbers in IDLE?

风流意气都作罢 提交于 2019-11-28 16:54:32
问题 In the main shell of IDLE, errors always return a line number but the development environment doesn't even have line numbers. Is there anyway to turn on line numbers? 回答1: Unfortunately there is not an option to display line numbers in IDLE although there is an enhancement request open for this. However, there are a couple of ways to work around this: Under the edit menu there is a go to line option (there is a default shortcut of Alt+G for this). There is a display at the bottom right which

python IDLE shell appears not to handle some escapes correctly

╄→гoц情女王★ 提交于 2019-11-28 14:38:23
For example \b backspace prints as quad (shown as [] in example below). But \n newline is Ok. >>> print 'abc\bd' abc[]d >>> print 'abc\nd' abc d Im running under Vista (pro), python 2.7 Ive tried googling this issue generally and in SO and cant find anything relevant, which seems odd and makes me wonder if theres some setting or other may be wrong in my setup. Not sure what to look for. What am I doing wrong or what should I be looking for? Is it reasonable to expect backspace, specifically, to work? No, IDLE does not support backspace, nor carriage-return, nor formfeed, nor ANSI escape

Python script run through IDLE has no output

无人久伴 提交于 2019-11-28 14:33:57
I’m using the Windows version of Python 2.7 with IDLE. If I run the following code import os os.getcwd() through IDLE (Run module F5), I get no output in the Python shell. If I double-click on test.py in Explorer, however, the current working directory is displayed. If I do a print command in IDLE, it shows up. Why doesn’t os.getcwd() have any output in IDLE, while print does? When you call a function, that function may return a value, and in this case os.getcwd() returns a string. Here, you never do anything to that string, so nothing happens - there's no output because you never print the

Importing from a Package in IDLE vs Shell

落花浮王杯 提交于 2019-11-28 14:28:10
Importing a whole package works in IDLE, but not in shell. The following works fine in IDLE: import tkinter as tk tk.filedialog.askopenfilename() In shell, I get this error: AttributeError: 'module' object has no attribute 'filedialog' I understand that I have to import tkinter.filedialog to make this work in shell. Why the difference between IDLE and shell? How can I make IDLE act like shell? It can be frustrating to have a script working in IDLE, and failing in shell. I am using Python 3.4. This is an IDLE bug which I fixed for future 3.5.3 and 3.6.0a4 releases. Tracker issue. For an

In Python IDLE, what's the difference between 'print'ing a variable and just writing the variable?

瘦欲@ 提交于 2019-11-28 14:16:29
At the IDLE interpreter I do the following with dpkt: for ts, buf in pcap: eth = dpkt.ethernet.Ethernet(buf) Now, when I try to see the contents of 'eth' I can either print it, or just write the variable name. When I do: print eth I get: O&áÿE(r @,òÀ¨ DYP?Jò}PªpÉ However, when I simply write: eth I get the more expected output of: Ethernet(src='<removed>', dst='<removed>', data=IP(src='<removed>', off=16384, dst='<removed>', sum=11506, len=40, p=6, ttl=128, id=29344, data=TCP(seq=2527752393, ack=218580057, win=16202, sum=62077, flags=16, dport=80, sport=51626))) So my question is, what's the

Basic Python Hello World Program Syntax Error

扶醉桌前 提交于 2019-11-28 14:14:32
I am not that really new in Programming but in Python I am really a newbie, and so when I started learning Python from the tutorials they encouraged me to use the IDLE editor for Python. And so as a newbie I had this weird Hello World problem. as you can see i use Python 2.6.6 in Linux(CentOS 6.2) and I tried almost all the possible syntaxes printing the simple HELLOWORLD provided in the documentation of python 2.6 and the new python 3 I tried printing contants like this print 1 + 1 and it work with an output >>> 2 I want to know how can i print this simple HELLOWORLD Jakub Hampl Check to make

Running Python script from IDLE on Windows 7 64 bit

ε祈祈猫儿з 提交于 2019-11-28 09:28:14
I'm trying to figure out how to successfully use Python 2.7.1 on windows 7. So far, I'm having to use the shell (IDLE) to create scripts and then run them from the cmd prompt. I feel this is slowing down the learning process and I was wondering if there was a way to run it from IDLE (I'm not able to create a pathway, so whenever i try to open or import a file i get an error) or some other program/text editor perhaps? Any help would be appreciated! I'm probably just doing something wrong. Run IDLE. You will be presented with the "Python Shell" window and a >>> prompt. Click File, New Window.

Unsupported characters in input In Python IDLE

六月ゝ 毕业季﹏ 提交于 2019-11-28 08:56:55
问题 suffixes = { 1: ["ो", "े", "ू", "ु", "ी", "ि", "ा"]} When I done message given by IDLE is Unsupported characters in input Also not see the proper font in MS-DOS. 回答1: What encoding is your source file in? If it is UTF8, put the comment # -*- coding: utf-8 -*- at the top of the file. 回答2: If you don't declare encoding in your first or second line in your python source file, then the python interpreter will use ASCII encoding system to decode the characters in the file. As these characters you

IDLE timeout parameter in Oracle

帅比萌擦擦* 提交于 2019-11-28 07:28:39
问题 We are stuck in a situation where one of our processes is taking 3 hours of computing without touching the database. The connection that was taken before calling the process gets closed by the Oracle server and any subsequent query or commit throws connection closed exception. It appears to us that the problem is related to Oracle closing the connection that is idle for that long for some reason. We tried changing EXPIRE_TIMEOUT in sqlnet.ora but that didn't help either. What can we do to

Close Python IDLE shell without prompt

女生的网名这么多〃 提交于 2019-11-28 06:30:29
问题 I am working on a script (script A), that needs to open a new Python IDLE shell, automatically run another script (script B) in it and then close it. The following code is what I use for this purpose: import sys sys.argv=['','-n','-t','My New Shell','-c','execfile("VarLoader.py")'] import idlelib.PyShell idlelib.PyShell.main() However I can't get the new shell close automatically. I have tried adding the following to script B but either it doesn't close the new shell or a windows pops up