Saving, loading, and recalling your work in the Python window—ArcMap (2024)

  • Saving your work
  • Loading Python into the Python window
  • Recalling Python code

Saving your work

The Python window provides a location to learn about and experiment with Python in an ArcGIS Desktop application. In many cases, it may be useful to save work done in the Python window to a file that can be referenced or used in later sessions.

The contents of the Python window can be saved to a Python file or text file. Right-click the Python window and select Save As to save your code either as a Python file (.py) or Text file (.txt). If saving to a Python file, only the Python code will be saved. If saving to a Text file, everything shown in the Python window, including the Python code, returned messages, and the command prompt (>>>), will be saved to the output file.

Saving, loading, and recalling your work in the Python window—ArcMap (1)

When saving code from the Python window, only the content that is currently in the Python window will be exported to the output file. Content that has been cleared or deleted will not be part of the saved file.

Loading Python into the Python window

The Python window is an interactive Python interpreter that is useful for quick execution of geoprocessing tools or other Python commands. However, code that has already been written and saved to a stand-alone script or Python file can also be loaded into the Python window, modified, and executed. Below is a simple script that looks at a feature class and field and produces a unique list of field values. The sample is simple enough, but entering all 13 lines manually into the Python window would take considerable time. Instead, by right-clicking in the Python window and selecting Load, this code (contained in a stand-alone script or Python file) is immediately loaded into the Python window. Once loaded into the Python window, edits can be made to the feature class location, field name, or syntax, and the code can be executed by hitting the ENTER key with the cursor at the last line of code.

Creates a unique list of field values based on a feature class and field name

import arcpyfeatureclass = "C:/data/county.gdb/hospital"field = "Zip"valueList = []rows = arcpy.da.SearchCursor(featureclass, [field])for row in rows: valueList.append(row[0])uniqueSet = set(valueList)uniqueList = list(uniqueSet)uniqueList.sort()print(uniqueList)

Recalling Python code

Lines of code executed in previous lines can be recalled using the up and down arrow keys. This recall inserts the specified line at the current command prompt location. The line of code can be edited and executed or run as-is a second time.

Saving, loading, and recalling your work in the Python window—ArcMap (2024)
Top Articles
GM believes 'production hell' is behind it with plans to build 20X more Ultium EVs in 2024
5 Clear Signs You’re Likely To Fail As A Real Estate Investor and Entrepreneur
Craigslist Warren Michigan Free Stuff
Victory Road Radical Red
Joliet Patch Arrests Today
Live Basketball Scores Flashscore
Chalupp's Pizza Taos Menu
Northern Whooping Crane Festival highlights conservation and collaboration in Fort Smith, N.W.T. | CBC News
Sam's Club Gas Price Hilliard
Strange World Showtimes Near Cmx Downtown At The Gardens 16
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Phillies Espn Schedule
fltimes.com | Finger Lakes Times
Discover Westchester's Top Towns — And What Makes Them So Unique
Evil Dead Rise Showtimes Near Regal Columbiana Grande
Raleigh Craigs List
Jc Post News
charleston cars & trucks - by owner - craigslist
Conan Exiles Colored Crystal
Best Forensic Pathology Careers + Salary Outlook | HealthGrad
Www Craigslist Milwaukee Wi
Kashchey Vodka
Bible Gateway passage: Revelation 3 - New Living Translation
Xsensual Portland
Purdue 247 Football
Egizi Funeral Home Turnersville Nj
Okc Body Rub
Darrell Waltrip Off Road Center
Wrights Camper & Auto Sales Llc
Tom Thumb Direct2Hr
Keshi with Mac Ayres and Starfall (Rescheduled from 11/1/2024) (POSTPONED) Tickets Thu, Nov 1, 2029 8:00 pm at Pechanga Arena - San Diego in San Diego, CA
Sacramento Craigslist Cars And Trucks - By Owner
Martins Point Patient Portal
Pay Stub Portal
Franklin Villafuerte Osorio
The Best Carry-On Suitcases 2024, Tested and Reviewed by Travel Editors | SmarterTravel
Telegram update adds quote formatting and new linking options
Alpha Asher Chapter 130
Cookie Clicker The Advanced Method
Restored Republic May 14 2023
Seven Rotten Tomatoes
21 Alive Weather Team
Blackwolf Run Pro Shop
Bmp 202 Blue Round Pill
Poster & 1600 Autocollants créatifs | Activité facile et ludique | Poppik Stickers
Craigslist Com Brooklyn
Spongebob Meme Pic
Ark Silica Pearls Gfi
Craigslist Charlestown Indiana
Https://Eaxcis.allstate.com
Emmi-Sellers
Latest Posts
Article information

Author: Dong Thiel

Last Updated:

Views: 5902

Rating: 4.9 / 5 (59 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Dong Thiel

Birthday: 2001-07-14

Address: 2865 Kasha Unions, West Corrinne, AK 05708-1071

Phone: +3512198379449

Job: Design Planner

Hobby: Graffiti, Foreign language learning, Gambling, Metalworking, Rowing, Sculling, Sewing

Introduction: My name is Dong Thiel, I am a brainy, happy, tasty, lively, splendid, talented, cooperative person who loves writing and wants to share my knowledge and understanding with you.