Browsing a File in Python

Browsing a File in Python thumbnail
IDLE simplifies file browsing in Python.

Sporting a reputation as a scripting tool deeply rooted in the command-line world of UNIX/Linux operating systems, browsing for files in Python sounds like a daunting endeavor. However, in its 20 years of development, Python has extended beyond mere scripting and embraced some of the more modern, user-friendly aspects of computing as they relate to the user interface. In addition to the traditional command line tools, Python now sports the IDLE integrated development environment (IDE), thus freeing the user from the bane of arcane file path commands.

Things You'll Need

  • Python 2.6 or higher
Show More

Instructions

    • 1

      Download the latest version of Python from python.org for your operating system and follow the installer directions. In addition to the command line tools, this will install several tools that simplify browsing and opening files. This installation will create a Python folder in your applications folder on your Mac and on your C: drive on a PC.

    • 2

      Open the Python folder and double-click on it. If you are using a PC, navigate to Idle from the start menu. Click on the "Start" menu, select "Programs," "Python," and then select "IDLE." This will open the interactive Python menu.

    • 3

      From the Idle menu bar choose "File" and then "Open." This opens a standard file browser window. Navigate to the file you want to open, select it and click "Open." Idle will only open files in plain text format and Python will only execute files with the .py suffix.

Tips & Warnings

  • As an alternative to browsing for files through the IDLE IDE, you can browse for files using the standard windowing system of your operating system. When you locate a file you want to run, drag it to the Python window and drop it on the Python launcher application. This will open the terminal on a Mac; on a PC, it opens a console window. On both systems, it will invoke the Python interpreter and run the program, automatically writing the file path to the interpreter, thus saving you much typing.

Related Searches:

References

  • Photo Credit Comstock Images/Comstock/Getty Images

Comments

Related Ads

Featured