Starting With Python

I have been writing a few geoprocessing scripts with Python recently, and have now even started to write scripts with more than one function..

I know I should sit down and read all the basics of a language first before using it, but where is the fun in that? I had written my main script, which called a couple of functions declared in the same .py file. I kept running into the following error:

“NameError: name ‘getMyFileTimes’ is not defined”

After looking a few times at how to declare functions, I realised eventually that they have to be declared before calling them. E.g.

def hello (what):
     text = “Hello, ” + what + “!”
     print text
 
hello (“World”)

I guess I am still getting used to writing in a scripting language in what amounts to little more than notepad, and it makes sense that if it is not compiled and read line by line then the function would not be “seen.” Still I miss my autosensing, and Visual Studio debugging tools a lot…



Discussion has just started! Join in...

  1. keith says:

    I recommend and use PyScripter, a light weight IDE, because it has intellisense and a debugger.

    What about Iron Python Studio?

    http://ironpythonstudio.codeplex.com/

    Keith

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment

You may use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>