Welcome to MEMpy
    Brad Montgomery
    http://mempy.org
print('hello world')
Python
• multi-platform
• multi-paradigm
• dynamically-typed
• big standard lib (tons of 3rd party libs)
• open source
• by Guido van Rossum (BDFL)
the interpreter

• An interactive Python shell
• In a *nix environment, open a terminal and
  type: python
• In Windows, run IDLE
IDLE
the interpreter
>>> print('hello world')
hello world
>>> 31 + 11
42
>>>
functions
# save this in a file named "greeting.py"
def hello(input_name='world'):
    greeting = "Hello {name}".format(
        name=input_name)
    return greeting


>>> from greeting import hello
>>>
>>> hello()
'Hello world'
>>>
>>> hello("Universe")
'Hello Universe'
modules/packages

• namespaces!
• module: a file with python code:
  greeting.py
• package: a directory of python modules
modules/packages


>>> from greetingapp import greeting
>>>
>>> greeting.hello()
'Hello world'
>>>
>>> greeting.hello("Universe")
'Hello Universe'
classes
class Greeter(object):
    names = ['World' ]

    def hello(self, names=None):
        if names:
            self.names = names

        for name in self.names:
            s = 'Hello {n}'.format(n=name)
            print(s)
classes
>>> from greeting import Greeter
>>> g = Greeter()
>>> g.hello()
Hello World
>>> g.hello(['Bill', 'Betty'])
Hello Bill
Hello Betty
>>>
who’s using python?
•   Google         •   EDU’s

•   YouTube        •   CERN

•   Nasa           •   ESRI

•   Astra-Zeneca   •   CCP Games

•   Lucasfilm       •   Silicon Valley Startups

•   Reddit         •   Hobbyists
learn more

• http://learnpythonthehardway.org/
• http://openbookproject.net/thinkCSpy/
• http://docs.python.org/tutorial/

Hello world

Editor's Notes