Select to view content in your preferred language

Real Cool Stuff on Python

2724
12
10-29-2009 10:39 AM
TedCronin
MVP Alum
So, far, the py window is pretty cool.  I type a little bit more here than with arcgisscripting, but really now, I think I will use this window over the command line window anyday even with the extra space ;).  Long Live the Python Window.  Now it doesn't beat Wing, but still pretty cool.

Should have tested this more in holistic.
0 Kudos
12 Replies
TedCronin
MVP Alum
I like we can now effectively put from ... import ... to use.
0 Kudos
TedCronin
MVP Alum
To facilitate the transfer of environment settings from one script to another and to save settings from one session to the next, settings can be saved to a file. ArcPy can then set its environments by loading a settings file.  This is pretty cool.  Awesome.


The only issue I have is why os.system, and not subprocess as part of the sample for calling the settings file.  Cool Nevertheless.
0 Kudos
TedCronin
MVP Alum
This was new at 9.3, but they are really cool.
0 Kudos
TedCronin
MVP Alum
Hi Ted,
Right, this is an enhancement at 9.4.  Less code, easier to understand.


At 9.3, you would have to use a while loop like so...

rows = gp.SearchCursor(myTable)
row = rows.next()
while row:
    print row.getValue("Rank")
    row = rows.next()

At 9.4, you can you use a for loop (you can also use the while loop approach if you desire)...

for row in arcpy.SearchCursor(myTable)
    print row.getValue("Rank")


-Dave   😛
0 Kudos
TedCronin
MVP Alum
arcpy.ListFiles("*.zip")
[u'C:\\GIS\\94\\CopyHome.zip', u'C:\\GIS\\94\\dd.zip', u'C:\\GIS\\94\\ESRI_AGOL_StreetMap_Web_Kit.zip', u'C:\\GIS\\94\\Python25.zip', u'C:\\GIS\\94\\Screenshots.zip', u'C:\\GIS\\94\\Topology.zip']

Cool functionality, no more glob.
0 Kudos
TedCronin
MVP Alum
Applicable to py and models.  This is very, very handy, and very cool.
0 Kudos
TedCronin
MVP Alum
I get the raw string inserted when dragging a path from Catalog, thats pretty cool.  Thank you GP Team.
0 Kudos
TedCronin
MVP Alum
import arcpy as ap

#ap.env.workspace = r'C:\94_testing'


versionList = ap.ListVersions(r'Database Connections\ACR_GIS@sdemapper - Test Server.sde')
#versionList.remove ('dbo.DEFAULT')
#versionList.remove ('ACR_FINAL.Master')

versionList.sort()

for version in versionList:
print version


So, this is pretty cool, and it is a real list. So, I am assuming we can just feed this into a delete and delete a bunch of versions at once. Very Cool, indeed. 😛
0 Kudos
StefanOffermann
Deactivated User
for row in arcpy.SearchCursor(myTable)
    print row.getValue("Rank")


Yeah, this is really really much more readable then in 9.3 Hooray! :cool:
0 Kudos