| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 70139 | 2006-06-23 05:52:00 | Looping in Python | Mike (15) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 465448 | 2006-06-24 06:57:00 | Hi Andrew, I would love to get into VBA, and am pushing my superiors to get me on courses etc. to get me started. The reason why I'm using Python is because it has turned out easier to disect that VBA, but probably more so because the application I'm writing these python scripts for uses python internally, and has a set of commands that I can load that are easily called from Python. Apparently the same can be done using VBA within this application, but the majority of users in the world are using python for their scripting, and so finding help (or even examples to disect) for this program is a lot harder than finding help for the python version (if you follow what I mean). The application (if you're wondering) is ESRI's ArcInfo - ArcGIS Desktop. Python is being used as a batch processor and a geoprocessor, to remove some of the very repetitive tasks involved in what I do. Cheers, Mike. |
Mike (15) | ||
| 465449 | 2006-06-24 07:09:00 | VBA for Unix anyone :D | dolby digital (5073) | ||
| 465450 | 2006-06-24 07:44:00 | Fair call Mike. That makes sense. That link I gave earlier has plenty of information - not just on loops. These sites might also help : docs.python.org www.microsoft.com www.codesampler.com And the difference between the C and Python syntax can be seen here (for Grahams benefit) : en.wikipedia.org A |
andrew93 (249) | ||
| 465451 | 2006-06-25 03:39:00 | Don't worry about it Andrew. I gave a couple of semantic examples of "generic" for loops: what they look like. I made no claim that they were syntactically correct for Python. (I think I have used it, but just to modify scripts.) Given the form of a construct I'm not familiar with, I can find out the syntactical details of a language; I assumed Mike is that smart. I don't like interpreters: like spreadsheets, they make it far too easy to get wrong answers. They are just allowable for scripting. I like strong block structure: I use indentation to show me the structure; I use begin/end (or even {/}) for the language processor. |
Graham L (2) | ||
| 465452 | 2006-06-26 21:55:00 | The for loop in Python doesn't follow the traditional for .... next syntax, it is more like this : MyArray = ['bird', 'cat', 'dog'] for MyVariable in MyArray: print MyVariableHi again Andrew, Can Python handle a semicolon instead of a comma to identify the different variables in the array? MyArray = ['bird'; 'cat'; 'dog'] - The reason being that my program can send variables in an array, but I'm pretty sure it splits them using semicolons... I haven't been able to check yet though. Cheers, Mike. |
Mike (15) | ||
| 465453 | 2006-06-27 10:03:00 | I've only ever used commas - there is more on the subject here : www.astro.ufl.edu Can you replace the semi-colons with commas before the Python process? There is a useful resource for ESRI users here: www.esri.com A |
andrew93 (249) | ||
| 1 2 | |||||