Case Sensitive!

2517
15
11-18-2010 05:23 AM
RDHarles
Occasional Contributor
What is going on with Arc 10 and the case sensitive stuff???

This works:
arcpy.Clip_management()

This doesn't!!!:
arcpy.clip_management()

Are you telling me I'm going to have to update literally hundreds of thousands of lines of code in hundreds of scripts in order to move from arc 9.x to  Arc 10?

Please tell me this isn't so?
Anyone figured out a way around this?
0 Kudos
15 Replies
RDHarles
Occasional Contributor
Chris & Ryan,
In my post above, I was kind of kidding, but I had the same thought.  It may not get it all done but it would certainly speed things up.  Hadn't thought of listtools(), that should work for the tool names (which would probably be half my battle).  Don't know if there's any way to get method & properties?
If you guys have any more ideas, let me know.
Thanks!
0 Kudos
FrankPerks
New Contributor II
import arcpy

def recase():
    tools = arcpy.listtools()
    for tool_name in tools:
        arcpy.globals()[tool_name.lower()] = arcpy.globals()[tool_name]

# add the case syntax
recase()


This should allow you to use lowercase syntax for arcpy.

What you guys really need though is a code refactoring tool. To update your code to the new syntax. Most Python IDE's (IDLE, pywin32, notepad, notepad++ ARE NOT IDE's i suggest Pycharm (http://www.jetbrains.com/pycharm/)) can do stuff like this.

Took me around 2 minutes for pycharm to refactor all of my scripts to the new arcpy syntax.
0 Kudos
RDHarles
Occasional Contributor
Frank,
Pycharm sounds interesting.  The only thing I know about refractoring tools is what I read in the last 5 minutes.
Could you very briefly explain what it takes to set up Pycharm to "fix" your code?
I'm curious.
Thanks.
0 Kudos
ChrisSnyder
Regular Contributor III
PyCharm looks cool ($100 though - actually $200 for me (govt.)) - but where's the interactive/immediate window?

I run this code in PyCharm:

import random
randomList = []
for i in range (1,11):
    randomList.append(random.random())


How can I view the contents of randomList?
0 Kudos
FrankPerks
New Contributor II
Frank,
Pycharm sounds interesting.  The only thing I know about refractoring tools is what I read in the last 5 minutes.
Could you very briefly explain what it takes to set up Pycharm to "fix" your code?
I'm curious.
Thanks.


Huh, i don't know why but ether the forums swallowed most of my post or i screwed up somehow sigh. The easiest way to change your code from arcgisscripting --> arcpy (however i don't know why you need to). Make a project add your scripts. Open up arcgisscripting  module from within pycharm (it will generate method stubs) for you from the dll. Copy everything, make a new module called arcgisscripting.py within your project. Just to be safe unload the real arcgisscripting library (remove it via the settings panel).

You can now then and go and refactor your copy, if you change the module name from arcgisscripting to arcpy (also unload the real arcpy) your scripts will update them selves. Then do the same for methods.

PyCharm looks cool ($100 though - actually $200 for me (govt.)) - but where's the interactive/immediate window?

I run this code in PyCharm:

import random
randomList = []
for i in range (1,11):
    randomList.append(random.random())


How can I view the contents of randomList?


I am not sure what you mean exactly by interactive/immediate..

If you want to view the value of something while the program runs ether:

Set a break point at the point you want to inspect. Hover over the variable, or go to the debug panel and look at the variables listed in your current stackframe.

Or add a watch (it is on the debug panel) and type the current name of the variable you want to monitor.

Nice.  I use Wingware, but this seems quite slick as well.  Thanks for the link.


Wingware IDE is amazing, however their licensing costs and limitations are horrific. Pycharms debugging is nowhere near are good as their debugging. However the price differences are night and day. Maybe someone should make a topic about IDE's.
0 Kudos
FrankPerks
New Contributor II
Limitation, can you be more specific? What are some problems that you have encountered?

The Free Wing 101 still works good. 
http://www.wingware.com/downloads/wingide-101/3.2.11-1/binaries

I have no association with Wing, other than using the product.

"Wing IDE 101 is free scaled down Python IDE designed for use in teaching introductory programming classes. It omits many features found in Wing IDE Professional and makes simplifications appropriate for beginners.The OS X version requires an X11 Server. "


Their licensing is based around OS Installs. So i cannot take their IDE and install it on my laptop since it has already been installed on my desktop. So wait. So that ~200$ CAD purchase turns into ~400$ CAD if i want to run it on my desktop and on my laptop. Also if you reinstall or change your hardware configuration you need to plead to technical support to get your key reinitialized. Compared to pycharm i have it happily installed on my desktop, and my laptop, and when i reinstall my os i don't need to contact technical support.

WingIDE 101 is a joke. It omits basic functionality that can be found in free IDE's like pyscripter, and Aptana. Once you take away the best features of WingIDE (code completetion, unit testing, debug probing, etc). All your left with is an ugly text editor.
0 Kudos