CS121
CS121
islower()
o String held in your variable remains the same
MODULE 1: INTRODUCTION TO PYTHON
o The method returns am altered by string
PROGRAMMING LANGUAGES
o Changing the variable requires reassignment
Introduction to Python - hw = hw.upper()
- hw now equals “HELLO WORLD”
o High-level programming language
o Open source and community driven List
o “Batteries Included”
o The information stays in the order you place
o Dynamic typed
it in until you modify that order
o Source can be compiled or run just in time
o Methods return a string or subset of the list
o Similar to perl, tcl, ruby
or modify the list to add or remove
Why Python? components
o Written as var[index], index refers to order
o There is a considerable base of developers within set (think card number, starting at 0)
already using the language
o “Tried and true” language that has been in Lists in ArcToolbox
development since 1991
o You will create lists:
o Can interface with the Component Object
- Layers as inputs
Model (COM) used by Windows
- Attributes to match
o Can interface with Open Source GIS toolsets
- Arrays of objects
Why not Visual Basic? o You will work with lists:
- List of field names
o VB is still the method of configuring and - List of selected features
customizing ArcMap
o Python scripts can be placed in Arc Toolbox Tuples
o Python can be run from the command line
o Iterable arrays of objects
without ArcMap
o Immutable – once created, unchangeable
o Rapid prototyping, ease of authoring, etc.
o Redeclare to add or remove items
Python Interfaces o Example uses
- County Names
o IDLE- a cross-platform Python development - Land use codes
environment - Ordered set of functions
- Color-coding
- Debugging Dictionaries
- Auto-indent
o Sets of key and value pairs
- Interactive Shell
o Allows to identify values by descriptive name
o PythonWin- a Windows only interface to
o Keys are unordered unless explicitly sorted
Python
o Keys are unique:
o Python Shell- running ‘python’ from the
- var[‘item’] = “apple”
command line opens this interactive shell
- var[‘item’] = “banana”
More than just printing - print var[‘item’] prints just
banana
o Python is an object oriented language
o “hello world” is a string Indention and Blocks