Python Window — Edit code after running it

607
5
12-17-2023 05:58 PM
Status: Closed
Labels (1)
Bud
by
Notable Contributor

ArcGIS Pro 3.2.1:

As a novice, it seems like I can't edit my Python code in the Python Window once the code has been executed. I need to retype (or paste) the code back into the prompt in order to edit it and rerun it.

Bud_0-1702864548752.png

If that's the case, then I'm wondering if that behaviour could be changed so that the code is persistent/editable after running it, similar to an IDE like PyScripter.

Bud_1-1702864646330.png

 

 

5 Comments
DanPatterson

hit the up arrow

py.png

See the help topic's Tip Python window—ArcGIS Pro | Documentation

for more options

or use Notebooks or your favourite python IDE

Luke_Pinner

It's an interpreter (REPL), not an editor or an IDE. The Jupyter Notebook interface might suit your way of working better?

BobBooth1

Hi Bud,

Try out this tutorial on using Python in a Notebook in ArcGIS Pro.

https://learn.arcgis.com/en/projects/get-started-with-notebooks-in-arcgis-pro/

Best,

Bob

BobBooth1

You may also be interested in these resources:

A set of tutorials on using Python in ArcGIS Pro:

https://learn.arcgis.com/en/paths/learn-python-in-arcgis-pro/

A set of tutorials on using Python in ArcGIS Notebooks (in ArcGIS Online):

https://learn.arcgis.com/en/paths/learn-python-with-arcgis-notebooks/

Converting code from a Notebook in ArcGIS Pro to a geoprocessing tool:

https://learngis.maps.arcgis.com/home/item.html?id=24e13f2f4fe8453b9d1107e1f5b1d3cf

 

 

HannesZiegler
Status changed to: Closed

Hi @Bud, as noted by @Luke_Pinner, the Python Window is an interactive terminal. Interactive terminals differ from an IDE experience and are not meant to replace IDEs. Instead, an interactive terminal is used to run Python code interactively. Think of it like a command line, where you run commands line by line and get results immediately. The Python Window is an interactive terminal integrated into ArcGIS Pro, which gives you some unique benefits as outlined in the Python Window documentation.

In an interactive terminal, you can edit previously entered code by pressing the up key on your keyboard (as @DanPatterson mentioned). You can then make changes and run the command (code) again. You can cycle through the history of commands executed during that session using the up/down arrows on your keyboard. This is a standard experience common to interactive terminals and command lines. 

To write a Python script or module (.py), you will need to use an Integrated Development Environment (IDE). You can find plenty of free and paid IDE options (and you mentioned one in your post) on the web. ArcGIS Pro is not an IDE, so you will need to turn to one of these third-party options for writing code at scale. (You can edit Script Tools in ArcGIS Pro using the script tool properties interface, but this is not a fully-fledged development environment experience and only for script tools.)

As @BobBooth1 already mentioned, there is also a third option; Jupyter Notebooks (.ipynb). Jupyter Notebooks are somewhat in-between the previous discussed options and can be run in ArcGIS Pro (see Notebooks in ArcGIS Pro to see the unique benefits this offers). This third option also is most similar to what you are describing in your idea, and they are very useful. I highly recommend checking these out if you haven't already.

In conclusion, the feature you are requesting will not be implemented as it goes against well-established patterns, but there are other existing tools to accomplish what you requested already offered either in ArcGIS Pro and/or by the broader Python community.

Good luck on your Python journey!