0

The read me says:

Copy IDLE2HTML.py to your the idlelib folder of your python installation. Append the contents of 'config-extensions.txt' to your 'config-extensions.def' file (also in the idlelib folder) and restart IDLE.

For more information on extending IDLE read 'config-main.def', 'config-extensions.def' and 'extend.txt'

Here is the code I am supposed to append from the txt file to the def file:

[IDLE2HTML]
enable=1
[IDLE2HTML_bindings]
idle2html=

My attempts to search for an answer led me to this post that had this code:

with open("test.txt", "a") as myfile:
    myfile.write("appended text")

but I had a few questions:

  1. Would that code work on a .def file or would only work for a .txt file
  2. The text I need to append is 4 lines, would I just have to run it 4 times using each of the four times as an input?
  3. Is there a way to append the .txt file directly on to the .def file?

Thanks in advance to any help I can get, I realize this is probably a very noob-y question but I am learning Python by following an online class and I have yet to learn how to work w/ reading and writing files.

Steve
  • 13
  • 3

2 Answers2

0

You don't need to do this programmatically. What the installation instructions are actually saying is:

1.) Navigate to the folder where idle.py is saved. On Windows this should be at: C:\Python27\Lib\idlelib or something similar. If you're having a hard time finding it on Windows you can right click on it in the Start menu and navigate to the Shortcut tab - this should show you where it is located. If you're on another OS I'm sure a quick Google search can help you out.

2.) Copy the IDLE2HTML.py file that you downloaded to this folder

3.) Within this folder there should also be a file called config-extensions.def. You can open this with Notepad (or any other simple text editor - just use right-click and "Open with") and copy/paste those four lines onto the end of the file and save.

If all goes well you should see the new behavior once you restart IDLE.

Terry Jan Reedy
  • 18,414
  • 3
  • 40
  • 52
HFBrowning
  • 2,196
  • 3
  • 23
  • 42
  • Ah! Thank you so much!!! **You can open this with Notepad (or any other simple text editor** I did not know this, thanks again! – Steve Aug 25 '17 at 00:07
0

If you can start IDLE, you can find the path to its directory as follows: on the top menu, click File, then Open Module. (The shortcut is Alt-M at least on Windows.) Enter idlelib. The title bar of the editor window will contain __init__.py - <path-to-idlelib>/__init__.py (x.y.z).

Terry Jan Reedy
  • 18,414
  • 3
  • 40
  • 52