Software Tool Seminar WS Taming the Snake

Size: px
Start display at page:

Download "Software Tool Seminar WS1516 - Taming the Snake"

Transcription

1 Software Tool Seminar WS Taming the Snake November 4, Taming the Snake 1.1 Understanding how Python works in N simple steps (with N still growing) 1.2 Step 0. What this talk is about (and what it isn t) Four basic things you need to learn to become a good programmer: 1. Learn how to express algorithms in a computer programming language 2. Learn how to design programs 3. Learn how your tool (the programming language) works and what it can offer you 4. Learn what others already have built for you I will only teach you how Python works. (And this is only the first part of it.) 1.3 Step 1. Everything is an object In Python, everything is an object. Examples: 42, 4.3, Hello world, True, False, None, [0, 1, 2, 3], { key : value, other key : other value } ( This, is, a, tuple ), np.eye(10) Really everything! math.sin, lambda x: x, class C, math, func. code To understand Python, we should first understand what objects are! 1.4 Step 2. The three properties of an object Objects have: 1. Identity 2. State 3. Methods 1

2 1.5 Step 3. The Identity of an object In [1]: a = [0, 1, 2] b = [0, 1, 2] a == b Out[1]: True In [2]: a is b Out[2]: False In [3]: id(a) Out[3]: In [4]: id(b) Out[4]: In [5]: (a is b) == (id(a) == id(b)) Out[5]: True In [6]: x = 6 y = 6 x is y Out[6]: True In [7]: x = 666 y = 666 x is y Out[7]: False In [8]: id(a) is id(a) Out[8]: False Do not use is unless you have a good reason! Reasonable exceptions: x is True x is False x is None This works because True, False, None are signletons in Python, i.e. there is only one object True, etc., in the whole Python universe. 2

3 1.6 Step 4. Understand assignment In [9]: import numpy as np a = np.ones(10) b = np.zeros(10) print(a) print(b) [ ] [ ] In [10]: a is b Out[10]: False In [11]: a = b print(a) print(b) [ ] [ ] In [12]: a[0] = 1 print(a) print(b) [ ] [ ] In [13]: a is b Out[13]: True Definition of assignment a = b means assign the name a to the object with name b Let s repeat! Definition of assignment a = b means assign the name a to the object with name b 3

4 1.7 Step 5. The state of an object Objects have state (data) associated to them, which can change over the lifetime of an object. The state is stored in the objects attributes. In [14]: from .mime.text import MIMEText m = MIMEText( Hi, this is an ! ) m Out[14]: < .mime.text.mimetext instance at 0x7f563c04cf38> In [15]: print(m.as_string()) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Hi, this is an ! In [16]: m._payload m._headers Out[16]: [( Content-Type, text/plain; charset="us-ascii" ), ( MIME-Version, 1.0 ), ( Content-Transfer-Encoding, 7bit )] The underscore means, payload and headers are private attributes. You, the user, should not mess around with them. Methods can change attributes: In [17]: m.add_header( From, [email protected] ) m.add_header( To, [email protected] ) m.add_header( Subject, World domination ) print(m.as_string()) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: [email protected] To: [email protected] Subject: World domination Hi, this is an ! In [18]: m._headers Out[18]: [( Content-Type, text/plain; charset="us-ascii" ), ( MIME-Version, 1.0 ), ( Content-Transfer-Encoding, 7bit ), ( From, [email protected] ), ( To, [email protected] ), ( Subject, World domination )] We can also change attributes, even private ones: (Do not try this at home!) In [19]: m._payload = We need to talk! print(m.as_string()) 4

5 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: To: Subject: World domination We need to talk! In [20]: m.my_attribute = 666 m.my_attribute Out[20]: Step 6. Understand the basics of attribute lookup So where do all these attributes come from? In [21]: m. dict Out[21]: { charset : us-ascii, default type : text/plain, headers : [( Content-Type, text/plain; charset="us-ascii" ), ( MIME-Version, 1.0 ), ( Content-Transfer-Encoding, 7bit ), ( From, [email protected] ), ( To, [email protected] ), ( Subject, World domination )], payload : We need to talk!, unixfrom : None, defects : [], epilogue : None, my attribute : 666, preamble : None} In [22]: m. dict [ favourite_song ] = Hotel california m. dict [ _payload ] = WE NEED TO TALK!!! In [23]: m.favourite_song Out[23]: Hotel california In [24]: print(m.as_string()) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: [email protected] To: [email protected] Subject: World domination WE NEED TO TALK!!! 5

6 1.7.2 Attribute lookup a.b means a. dict [ b ] In [25]: a = np.eye(10) a.secret_answer = AttributeError <ipython-input-25-9d909bc47556> in <module>() 1 a = np.eye(10) ----> 2 a.secret answer = 42 AttributeError: numpy.ndarray object has no attribute secret answer In [26]: a. dict AttributeError <ipython-input-26-87da7e691200> in <module>() ----> 1 a. dict AttributeError: numpy.ndarray object has no attribute dict In [27]: (42). dict AttributeError <ipython-input-27-f22e1a648ac9> in <module>() ----> 1 (42). dict AttributeError: int object has no attribute dict 6

7 In [28]: [0, 1, 2]. dict AttributeError <ipython-input-28-cb92ad523bf5> in <module>() ----> 1 [0, 1, 2]. dict AttributeError: list object has no attribute dict Attribute lookup If a has a dict, a.b means a. dict [ b ] This is not the case for builtin types or C extension types. In [29]: class C(object): pass Out[29]: {} c = C() c. dict In [30]: c.secret_answer = 42 c. dict Out[30]: { secret answer : 42} In [31]: class C(object): secret_answer = 42 Out[31]: 42 c = C() c.secret_answer In [32]: c. dict Out[32]: {} In [33]: c. class Out[33]: main.c In [34]: c. class. dict Out[34]: <dictproxy { dict : <attribute dict of C objects>, doc : None, module : main, weakref : <attribute weakref of C objects>, secret answer : 42}> 7

8 1.7.4 Attribute lookup (simplified) If a has a dict, a.b means if b in a. dict : return a. dict [ b ] elif b in a. class. dict : return a. class. dict [ b ] elif b in base class dicts : return base_class. dict [ b ] else: raise AttributeError This is not the case for builtin types or C extension types Step 7. Be careful with class attributes In [35]: class C(object): great_list_of_awesomeness = [] c1 = C() c2 = C() In [36]: c1.great_list_of_awesomeness.append(42) c1.great_list_of_awesomeness Out[36]: [42] In [37]: c2.great_list_of_awesomeness Out[37]: [42] This might not be what you want! Step 8. Understand methods Methods are functions defined in class definitions as follows: In [38]: class C(object): Out[38]: 42 def init (self, x): self.x = x def f(self, y): return self.x + y c = C(11) c.f(31) 8

9 c.f(31) translates to C.f(c, 31) i.e. calling a method on an object c magically inserts c as first argument of the method. This also explains this strange error: In [39]: c.f() TypeError <ipython-input-39-69c69864e152> in <module>() ----> 1 c.f() TypeError: f() takes exactly 2 arguments (1 given) init is one of Python s many special methods. It is called, after a new object has been created. Thus c = C(11) translates to c = newly_created_c_instance c. init (c, 11) We can add new methods to the class at any time: In [40]: def g(ego, y): return ego.x * y Out[40]: 22 C.mult = g c.mult(2) Note that self as first argument name is pure convention. You should really stick to it! Adding functions directly to objects does not work: In [41]: def h(self, y): return self.x - y c.h = h c.h(-31) 9

10 TypeError <ipython-input-41-f498a20a0d9d> in <module>() 3 4 c.h = h ----> 5 c.h(-31) TypeError: h() takes exactly 2 arguments (1 given) Oh no, the magic is not working! In [42]: import types c.h = types.methodtype(h, c) c.h(-31) Out[42]: Step 9. Understand immutable objects Numbers, strings and tuples are immutable in Python: In [43]: t = (0, 1, 2) t[1] = TypeError <ipython-input-43-4ca911cddf58> in <module>() 1 t = (0, 1, 2) ----> 2 t[1] = 2 TypeError: tuple object does not support item assignment There is absolutely no way to modify them! So what about here: In [44]: x = 41 y = x x += 1 In [45]: y Out[45]: 41 10

11 In [46]: x is y Out[46]: False In [47]: x Out[47]: 42 So, x refers to a new int object with value 42. Think what would have happend, if the object had stayed the same! This is, how inplace addition works: In [48]: class MyNumber(object): def init (self, value): self.value = value def iadd (self, other): return MyNumber(self.value + other) In [49]: n = MyNumber(12) print(n.value) print(id(n)) n += 7 print(n.value) print(id(n)) n += 7 is really the same as n = n. iadd (7) What happens here? In [50]: class C(object): value = 42 c1 = C() c2 = C() c1.value = 666 In [51]: c1.value Out[51]: 666 In [52]: c2.value Out[52]: 42 In [53]: print(c1. dict ) print(c2. dict ) print(c. dict ) { value : 666} {} { dict : <attribute dict of C objects>, module : main, weakref : <attribute wea 11

12 1.7.8 Step 10. Be careful with default arguments: Default arguments are attributes of the function object: In [54]: def f(x, more_values=[]): more_values.append(x) print(more_values) In [55]: f. defaults Out[55]: ([],) In [56]: print(dir(f)) [ call, class, closure, code, defaults, delattr, dict, doc, for In [57]: def f(x, more_values=[]): more_values.append(x) print(more_values) In [58]: f(1) [1] In [59]: f(42, [4, 8, 15, 16, 23, 42]) [4, 8, 15, 16, 23, 42, 42] In [60]: f(1) f(1) [1, 1] [1, 1, 1] In [61]: f. defaults Out[61]: ([1, 1, 1],) In [62]: f. defaults = ([],) f(1) [1] 12

Objects and classes. Objects and classes. Jarkko Toivonen (CS Department) Programming in Python 1

Objects and classes. Objects and classes. Jarkko Toivonen (CS Department) Programming in Python 1 Objects and classes Jarkko Toivonen (CS Department) Programming in Python 1 Programming paradigms of Python Python is an object-oriented programming language like Java and C++ But unlike Java, Python doesn

More information

ESCI 386 Scientific Programming, Analysis and Visualization with Python. Lesson 5 Program Control

ESCI 386 Scientific Programming, Analysis and Visualization with Python. Lesson 5 Program Control ESCI 386 Scientific Programming, Analysis and Visualization with Python Lesson 5 Program Control 1 Interactive Input Input from the terminal is handled using the raw_input() function >>> a = raw_input('enter

More information

CIS 192: Lecture 10 Web Development with Flask

CIS 192: Lecture 10 Web Development with Flask CIS 192: Lecture 10 Web Development with Flask Lili Dworkin University of Pennsylvania Last Week s Quiz req = requests.get("http://httpbin.org/get") 1. type(req.text) 2. type(req.json) 3. type(req.json())

More information

Introduction to Python

Introduction to Python WEEK ONE Introduction to Python Python is such a simple language to learn that we can throw away the manual and start with an example. Traditionally, the first program to write in any programming language

More information

CS177 MIDTERM 2 PRACTICE EXAM SOLUTION. Name: Student ID:

CS177 MIDTERM 2 PRACTICE EXAM SOLUTION. Name: Student ID: CS177 MIDTERM 2 PRACTICE EXAM SOLUTION Name: Student ID: This practice exam is due the day of the midterm 2 exam. The solutions will be posted the day before the exam but we encourage you to look at the

More information

Exercise 4 Learning Python language fundamentals

Exercise 4 Learning Python language fundamentals Exercise 4 Learning Python language fundamentals Work with numbers Python can be used as a powerful calculator. Practicing math calculations in Python will help you not only perform these tasks, but also

More information

Instruction Set Architecture of Mamba, a New Virtual Machine for Python

Instruction Set Architecture of Mamba, a New Virtual Machine for Python Instruction Set Architecture of Mamba, a New Virtual Machine for Python David Pereira and John Aycock Department of Computer Science University of Calgary 2500 University Drive N.W. Calgary, Alberta, Canada

More information

Introduction to Python

Introduction to Python Caltech/LEAD Summer 2012 Computer Science Lecture 2: July 10, 2012 Introduction to Python The Python shell Outline Python as a calculator Arithmetic expressions Operator precedence Variables and assignment

More information

Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

More information

Obfuscation: know your enemy

Obfuscation: know your enemy Obfuscation: know your enemy Ninon EYROLLES [email protected] Serge GUELTON [email protected] Prelude Prelude Plan 1 Introduction What is obfuscation? 2 Control flow obfuscation 3 Data flow

More information

Chapter 2 Writing Simple Programs

Chapter 2 Writing Simple Programs Chapter 2 Writing Simple Programs Charles Severance Textbook: Python Programming: An Introduction to Computer Science, John Zelle Software Development Process Figure out the problem - for simple problems

More information

Static vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer

Static vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer Lecture 10: Static Semantics Overview 1 Lexical analysis Produces tokens Detects & eliminates illegal tokens Parsing Produces trees Detects & eliminates ill-formed parse trees Static semantic analysis

More information

Crash Dive into Python

Crash Dive into Python ECPE 170 University of the Pacific Crash Dive into Python 2 Lab Schedule Ac:vi:es Assignments Due Today Lab 8 Python Due by Oct 26 th 5:00am Endianness Lab 9 Tuesday Due by Nov 2 nd 5:00am Network programming

More information

Python for Rookies. Example Examination Paper

Python for Rookies. Example Examination Paper Python for Rookies Example Examination Paper Instructions to Students: Time Allowed: 2 hours. This is Open Book Examination. All questions carry 25 marks. There are 5 questions in this exam. You should

More information

Introduction to Python for Text Analysis

Introduction to Python for Text Analysis Introduction to Python for Text Analysis Jennifer Pan Institute for Quantitative Social Science Harvard University (Political Science Methods Workshop, February 21 2014) *Much credit to Andy Hall and Learning

More information

CSCE 110 Programming I Basics of Python: Variables, Expressions, and Input/Output

CSCE 110 Programming I Basics of Python: Variables, Expressions, and Input/Output CSCE 110 Programming Basics of Python: Variables, Expressions, and nput/output Dr. Tiffani L. Williams Department of Computer Science and Engineering Texas A&M University Fall 2011 Python Python was developed

More information

Python Programming: An Introduction To Computer Science

Python Programming: An Introduction To Computer Science Python Programming: An Introduction To Computer Science Chapter 8 Booleans and Control Structures Python Programming, 2/e 1 Objectives æ To understand the concept of Boolean expressions and the bool data

More information

Today s Topics... Intro to Computer Science (cont.) Python exercise. Reading Assignment. Ch 1: 1.5 (through 1.5.2) Lecture Notes CPSC 121 (Fall 2011)

Today s Topics... Intro to Computer Science (cont.) Python exercise. Reading Assignment. Ch 1: 1.5 (through 1.5.2) Lecture Notes CPSC 121 (Fall 2011) Today s Topics... Intro to Computer Science (cont.) Python exercise Reading Assignment Ch 1: 1.5 (through 1.5.2) S. Bowers 1 of 8 Computation (cont.) What parts do recipes usually have? A description (the

More information

[1] Learned how to set up our computer for scripting with python et al. [3] Solved a simple data logistics problem using natural language/pseudocode.

[1] Learned how to set up our computer for scripting with python et al. [3] Solved a simple data logistics problem using natural language/pseudocode. Last time we... [1] Learned how to set up our computer for scripting with python et al. [2] Thought about breaking down a scripting problem into its constituent steps. [3] Solved a simple data logistics

More information

Chapter 3 Writing Simple Programs. What Is Programming? Internet. Witin the web server we set lots and lots of requests which we need to respond to

Chapter 3 Writing Simple Programs. What Is Programming? Internet. Witin the web server we set lots and lots of requests which we need to respond to Chapter 3 Writing Simple Programs Charles Severance Unless otherwise noted, the content of this course material is licensed under a Creative Commons Attribution 3.0 License. http://creativecommons.org/licenses/by/3.0/.

More information

Introduction to Python

Introduction to Python 1 Daniel Lucio March 2016 Creator of Python https://en.wikipedia.org/wiki/guido_van_rossum 2 Python Timeline Implementation Started v1.0 v1.6 v2.1 v2.3 v2.5 v3.0 v3.1 v3.2 v3.4 1980 1991 1997 2004 2010

More information

Building and breaking a Python sandbox

Building and breaking a Python sandbox Building and breaking a Python sandbox Director Organizer @jessicamckellar http://jesstess.com Why? Learning a language Providing a hosted scratch pad Distributed computation Inspecting running processes

More information

Computer Science for San Francisco Youth

Computer Science for San Francisco Youth Python for Beginners Python for Beginners Lesson 0. A Short Intro Lesson 1. My First Python Program Lesson 2. Input from user Lesson 3. Variables Lesson 4. If Statements How If Statements Work Structure

More information

Self-review 9.3 What is PyUnit? PyUnit is the unit testing framework that comes as standard issue with the Python system.

Self-review 9.3 What is PyUnit? PyUnit is the unit testing framework that comes as standard issue with the Python system. Testing, Testing 9 Self-Review Questions Self-review 9.1 What is unit testing? It is testing the functions, classes and methods of our applications in order to ascertain whether there are bugs in the code.

More information

Python Loops and String Manipulation

Python Loops and String Manipulation WEEK TWO Python Loops and String Manipulation Last week, we showed you some basic Python programming and gave you some intriguing problems to solve. But it is hard to do anything really exciting until

More information

Optimizing and interfacing with Cython. Konrad HINSEN Centre de Biophysique Moléculaire (Orléans) and Synchrotron Soleil (St Aubin)

Optimizing and interfacing with Cython. Konrad HINSEN Centre de Biophysique Moléculaire (Orléans) and Synchrotron Soleil (St Aubin) Optimizing and interfacing with Cython Konrad HINSEN Centre de Biophysique Moléculaire (Orléans) and Synchrotron Soleil (St Aubin) Extension modules Python permits modules to be written in C. Such modules

More information

Profiling, debugging and testing with Python. Jonathan Bollback, Georg Rieckh and Jose Guzman

Profiling, debugging and testing with Python. Jonathan Bollback, Georg Rieckh and Jose Guzman Profiling, debugging and testing with Python Jonathan Bollback, Georg Rieckh and Jose Guzman Overview 1.- Profiling 4 Profiling: timeit 5 Profiling: exercise 6 2.- Debugging 7 Debugging: pdb 8 Debugging:

More information

flask-mail Documentation

flask-mail Documentation flask-mail Documentation Release 0.9.1 Dan Jacob February 16, 2016 Contents 1 Links 3 2 Installing Flask-Mail 5 3 Configuring Flask-Mail 7 4 Sending messages 9 5 Bulk emails 11 6 Attachments 13 7 Unit

More information

Crash Dive into Python

Crash Dive into Python ECPE 170 University of the Pacific Crash Dive into Python 2 Lab Schedule Ac:vi:es Assignments Due Today Lab 11 Network Programming Due by Dec 1 st 5:00am Python Lab 12 Next Week Due by Dec 8 th 5:00am

More information

Exercise 1: Python Language Basics

Exercise 1: Python Language Basics Exercise 1: Python Language Basics In this exercise we will cover the basic principles of the Python language. All languages have a standard set of functionality including the ability to comment code,

More information

Slides from INF3331 lectures - web programming in Python

Slides from INF3331 lectures - web programming in Python Slides from INF3331 lectures - web programming in Python Joakim Sundnes & Hans Petter Langtangen Dept. of Informatics, Univ. of Oslo & Simula Research Laboratory October 2013 Programming web applications

More information

Integrating Fax Sending Services

Integrating Fax Sending Services Integrating Fax Sending Services Developer Guide Enabled by Popfax Integrating Fax Sending Services Using SMTP API (mail to fax) DEVELOPER GUIDE Enabled by Popfax We recommend developers to register as

More information

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share. LING115 Lecture Note Session #4 Python (1) 1. Introduction As we have seen in previous sessions, we can use Linux shell commands to do simple text processing. We now know, for example, how to count words.

More information

Intro to scientific programming (with Python) Pietro Berkes, Brandeis University

Intro to scientific programming (with Python) Pietro Berkes, Brandeis University Intro to scientific programming (with Python) Pietro Berkes, Brandeis University Next 4 lessons: Outline Scientific programming: best practices Classical learning (Hoepfield network) Probabilistic learning

More information

Introduction to Big Data with Apache Spark UC BERKELEY

Introduction to Big Data with Apache Spark UC BERKELEY Introduction to Big Data with Apache Spark UC BERKELEY This Lecture Programming Spark Resilient Distributed Datasets (RDDs) Creating an RDD Spark Transformations and Actions Spark Programming Model Python

More information

Python Classes and Objects

Python Classes and Objects Python Classes and Objects A Basic Introduction Coming up: Topics 1 Topics Objects and Classes Abstraction Encapsulation Messages What are objects An object is a datatype that stores data, but ALSO has

More information

Chapter 7: Functional Programming Languages

Chapter 7: Functional Programming Languages Chapter 7: Functional Programming Languages Aarne Ranta Slides for the book Implementing Programming Languages. An Introduction to Compilers and Interpreters, College Publications, 2012. Fun: a language

More information

Sources: On the Web: Slides will be available on:

Sources: On the Web: Slides will be available on: C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

More information

PHP Magic Tricks: Type Juggling. PHP Magic Tricks: Type Juggling

PHP Magic Tricks: Type Juggling. PHP Magic Tricks: Type Juggling Who Am I Chris Smith (@chrismsnz) Previously: Polyglot Developer - Python, PHP, Go + more Linux Sysadmin Currently: Pentester, Consultant at Insomnia Security Little bit of research Insomnia Security Group

More information

Python Evaluation Rules

Python Evaluation Rules Python Evaluation Rules UW CSE 160 http://tinyurl.com/dataprogramming Michael Ernst and Isaac Reynolds [email protected] August 2, 2016 Contents 1 Introduction 2 1.1 The Structure of a Python Program................................

More information

Computers. An Introduction to Programming with Python. Programming Languages. Programs and Programming. CCHSG Visit June 2014. Dr.-Ing.

Computers. An Introduction to Programming with Python. Programming Languages. Programs and Programming. CCHSG Visit June 2014. Dr.-Ing. Computers An Introduction to Programming with Python CCHSG Visit June 2014 Dr.-Ing. Norbert Völker Many computing devices are embedded Can you think of computers/ computing devices you may have in your

More information

The PHP 5.4 Features You Will Actually Use

The PHP 5.4 Features You Will Actually Use The PHP 5.4 Features You Will Actually Use About Me Lorna Jane Mitchell PHP Consultant/Developer Author of PHP Master Twitter: @lornajane Website: http://lornajane.net 2 About PHP 5.4 New features Traits

More information

requests_toolbelt Documentation

requests_toolbelt Documentation requests_toolbelt Documentation Release 0.1.0 Ian Cordasco, Cory Benfield March 14, 2015 Contents 1 User Guide 3 1.1 Streaming Multipart Data Encoder.................................... 3 1.2 User-Agent

More information

A skip list container class in Python

A skip list container class in Python A skip list container class in Python Abstract An alternative to balanced trees John W. Shipman 2012-11-29 13:23 Describes a module in the Python programming language that implements a skip list, a data

More information

CIS 192: Lecture 13 Scientific Computing and Unit Testing

CIS 192: Lecture 13 Scientific Computing and Unit Testing CIS 192: Lecture 13 Scientific Computing and Unit Testing Lili Dworkin University of Pennsylvania Scientific Computing I Python is really popular in the scientific and statistical computing world I Why?

More information

Python Objects. Charles Severance www.pythonlearn.com. http://en.wikipedia.org/wiki/object-oriented_programming

Python Objects. Charles Severance www.pythonlearn.com. http://en.wikipedia.org/wiki/object-oriented_programming Python Objects Charles Severance www.pythonlearn.com http://en.wikipedia.org/wiki/object-oriented_programming Warning This lecture is very much about definitions and mechanics for objects This lecture

More information

2! Multimedia Programming with! Python and SDL

2! Multimedia Programming with! Python and SDL 2 Multimedia Programming with Python and SDL 2.1 Introduction to Python 2.2 SDL/Pygame: Multimedia/Game Frameworks for Python Literature: G. van Rossum and F. L. Drake, Jr., An Introduction to Python -

More information

Exercise 0. Although Python(x,y) comes already with a great variety of scientic Python packages, we might have to install additional dependencies:

Exercise 0. Although Python(x,y) comes already with a great variety of scientic Python packages, we might have to install additional dependencies: Exercise 0 Deadline: None Computer Setup Windows Download Python(x,y) via http://code.google.com/p/pythonxy/wiki/downloads and install it. Make sure that before installation the installer does not complain

More information

6.170 Tutorial 3 - Ruby Basics

6.170 Tutorial 3 - Ruby Basics 6.170 Tutorial 3 - Ruby Basics Prerequisites 1. Have Ruby installed on your computer a. If you use Mac/Linux, Ruby should already be preinstalled on your machine. b. If you have a Windows Machine, you

More information

CIS 192: Lecture 10 Web Development with Flask

CIS 192: Lecture 10 Web Development with Flask CIS 192: Lecture 10 Web Development with Flask Lili Dworkin University of Pennsylvania Web Frameworks We ve been talking about making HTTP requests What about serving them? Flask is a microframework small

More information

Tutorial. Reference http://www.openflowswitch.org/foswiki/bin/view/openflow/mininetgettingstarted for more thorough Mininet walkthrough if desired

Tutorial. Reference http://www.openflowswitch.org/foswiki/bin/view/openflow/mininetgettingstarted for more thorough Mininet walkthrough if desired Setup Tutorial Reference http://www.openflowswitch.org/foswiki/bin/view/openflow/mininetgettingstarted for more thorough Mininet walkthrough if desired Necessary Downloads 1. Download VM at http://www.cs.princeton.edu/courses/archive/fall10/cos561/assignments/cos561tutorial.zip

More information

Unit testing with mock code EuroPython 2004 Stefan Schwarzer p.1/25

Unit testing with mock code EuroPython 2004 Stefan Schwarzer p.1/25 Unit testing with mock code EuroPython 2004 Stefan Schwarzer [email protected] Informationsdienst Wissenschaft e. V. Unit testing with mock code EuroPython 2004 Stefan Schwarzer p.1/25 Personal

More information

Introduction to Programming Languages and Techniques. xkcd.com FULL PYTHON TUTORIAL

Introduction to Programming Languages and Techniques. xkcd.com FULL PYTHON TUTORIAL Introduction to Programming Languages and Techniques xkcd.com FULL PYTHON TUTORIAL Last updated 9/1/2014 Full Python Tutorial Developed by Guido van Rossum in the early 1990s Named after Monty Python Available

More information

Sorting. Lists have a sort method Strings are sorted alphabetically, except... Uppercase is sorted before lowercase (yes, strange)

Sorting. Lists have a sort method Strings are sorted alphabetically, except... Uppercase is sorted before lowercase (yes, strange) Sorting and Modules Sorting Lists have a sort method Strings are sorted alphabetically, except... L1 = ["this", "is", "a", "list", "of", "words"] print L1 ['this', 'is', 'a', 'list', 'of', 'words'] L1.sort()

More information

Server-side Development using Python and SQL

Server-side Development using Python and SQL Lab 2 Server-side Development using Python and SQL Authors: Sahand Sadjadee Alexander Kazen Gustav Bylund Per Jonsson Tobias Jansson Spring 2015 TDDD97 Web Programming http://www.ida.liu.se/~tddd97/ Department

More information

Programming Exercises

Programming Exercises s CMPS 5P (Professor Theresa Migler-VonDollen ): Assignment #8 Problem 6 Problem 1 Programming Exercises Modify the recursive Fibonacci program given in the chapter so that it prints tracing information.

More information

University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python

University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python Introduction Welcome to our Python sessions. University of Hull Department of Computer Science Wrestling with Python Week 01 Playing with Python Vsn. 1.0 Rob Miles 2013 Please follow the instructions carefully.

More information

CPSC 360 - Network Programming. Email, FTP, and NAT. http://www.cs.clemson.edu/~mweigle/courses/cpsc360

CPSC 360 - Network Programming. Email, FTP, and NAT. http://www.cs.clemson.edu/~mweigle/courses/cpsc360 CPSC 360 - Network Programming E, FTP, and NAT Michele Weigle Department of Computer Science Clemson University [email protected] April 18, 2005 http://www.cs.clemson.edu/~mweigle/courses/cpsc360

More information

7 Why Use Perl for CGI?

7 Why Use Perl for CGI? 7 Why Use Perl for CGI? Perl is the de facto standard for CGI programming for a number of reasons, but perhaps the most important are: Socket Support: Perl makes it easy to create programs that interface

More information

Deterministic Discrete Modeling

Deterministic Discrete Modeling Deterministic Discrete Modeling Formal Semantics of Firewalls in Isabelle/HOL Cornelius Diekmann, M.Sc. Dr. Heiko Niedermayer Prof. Dr.-Ing. Georg Carle Lehrstuhl für Netzarchitekturen und Netzdienste

More information

Things you didn't know about Python

Things you didn't know about Python Things you didn't know about Python a presentation by Armin Ronacher for PyCon South Africa 2012 @mitsuhiko http://lucumr.pocoo.org/ Things you didn't know about Python might already know computers a presentation

More information

COMP 112 Assignment 1: HTTP Servers

COMP 112 Assignment 1: HTTP Servers COMP 112 Assignment 1: HTTP Servers Lead TA: Jim Mao Based on an assignment from Alva Couch Tufts University Due 11:59 PM September 24, 2015 Introduction In this assignment, you will write a web server

More information

ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters

ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters The char Type ASCII Encoding The C char type stores small integers. It is usually 8 bits. char variables guaranteed to be able to hold integers 0.. +127. char variables mostly used to store characters

More information

CS106A, Stanford Handout #38. Strings and Chars

CS106A, Stanford Handout #38. Strings and Chars CS106A, Stanford Handout #38 Fall, 2004-05 Nick Parlante Strings and Chars The char type (pronounced "car") represents a single character. A char literal value can be written in the code using single quotes

More information

Tools and Techniques for Developing Atmospheric Python Software: Insight from the Python ARM Radar Toolkit

Tools and Techniques for Developing Atmospheric Python Software: Insight from the Python ARM Radar Toolkit Tools and Techniques for Developing Atmospheric Python Software: Insight from the Python ARM Radar Toolkit Jonathan Helmus1, Scott Giangrande2, Kirk North3, and Scott Collis1 1 2 Argonne National Laboratory

More information

latest Release 0.2.6

latest Release 0.2.6 latest Release 0.2.6 August 19, 2015 Contents 1 Installation 3 2 Configuration 5 3 Django Integration 7 4 Stand-Alone Web Client 9 5 Daemon Mode 11 6 IRC Bots 13 7 Bot Events 15 8 Channel Events 17 9

More information

Name Spaces. Introduction into Python Python 5: Classes, Exceptions, Generators and more. Classes: Example. Classes: Briefest Introduction

Name Spaces. Introduction into Python Python 5: Classes, Exceptions, Generators and more. Classes: Example. Classes: Briefest Introduction Name Spaces Introduction into Python Python 5: Classes, Exceptions, Generators and more Daniel Polani Concept: There are three different types of name spaces: 1. built-in names (such as abs()) 2. global

More information

Writing Simple Programs

Writing Simple Programs Chapter 2 Writing Simple Programs Objectives To know the steps in an orderly software development process. To understand programs following the Input, Process, Output (IPO) pattern and be able to modify

More information

Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

More information

Organization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.

Organization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio. Organization of Programming Languages CS320/520N Razvan C. Bunescu School of Electrical Engineering and Computer Science [email protected] Names, Bindings, and Scopes A name is a symbolic identifier used

More information

ft6 Motivation next step: perform the tests usually tedious, error prone work aided by a tool easily repeatable enter ft6 ft6

ft6 Motivation next step: perform the tests usually tedious, error prone work aided by a tool easily repeatable enter ft6 ft6 ft6 Motivation next step: perform the tests usually tedious, error prone work aided by a tool easily repeatable enter ft6 Oliver Eggert (Universität Potsdam) ft6: firewall tester for IPv6 Folie 1 von 25

More information

Email Electronic Mail

Email Electronic Mail Email Electronic Mail Electronic mail paradigm Most heavily used application on any network Electronic version of paper-based office memo Quick, low-overhead written communication Dates back to time-sharing

More information

Using EDA Databases: Milkyway & OpenAccess

Using EDA Databases: Milkyway & OpenAccess Using EDA Databases: Milkyway & OpenAccess Enabling and Using Scripting Languages with Milkyway and OpenAccess Don Amundson Khosro Khakzadi 2006 LSI Logic Corporation 1 Outline History Choice Of Scripting

More information

Overview. Elements of Programming Languages. Advanced constructs. Motivating inner class example

Overview. Elements of Programming Languages. Advanced constructs. Motivating inner class example Overview Elements of Programming Languages Lecture 12: Object-oriented functional programming James Cheney University of Edinburgh November 6, 2015 We ve now covered: basics of functional and imperative

More information

Time Clock Import Setup & Use

Time Clock Import Setup & Use Time Clock Import Setup & Use Document # Product Module Category CenterPoint Payroll Processes (How To) This document outlines how to setup and use of the Time Clock Import within CenterPoint Payroll.

More information

COMS 3101-3 Programming Languages Python: Lecture 1. Kangkook Jee [email protected]

COMS 3101-3 Programming Languages Python: Lecture 1. Kangkook Jee jikk@cs.columbia.edu COMS 3101-3 Programming Languages Python: Lecture 1 Kangkook Jee [email protected] Agenda Course descripgon IntroducGon to Python Language aspects and usage cases GeJng started How to run Python Basic

More information

An extension to DBAPI 2.0 for easier SQL queries

An extension to DBAPI 2.0 for easier SQL queries An extension to DBAPI 2.0 for easier SQL queries Martin Blais EWT LLC / Madison Tyler http://furius.ca/antiorm/ Introduction connection = dbapi.connect(...) cursor = connection.cursor() SELECT * FROM Users

More information

The Clean programming language. Group 25, Jingui Li, Daren Tuzi

The Clean programming language. Group 25, Jingui Li, Daren Tuzi The Clean programming language Group 25, Jingui Li, Daren Tuzi The Clean programming language Overview The Clean programming language first appeared in 1987 and is still being further developed. It was

More information

Lecture 8. IP Fundamentals

Lecture 8. IP Fundamentals Lecture 8. Internet Network Layer: IP Fundamentals Outline Layer 3 functionalities Internet Protocol (IP) characteristics IP packet (first look) IP addresses Routing tables: how to use ARP Layer 3 functionalities

More information

PostgreSQL Functions By Example

PostgreSQL Functions By Example Postgre [email protected] credativ Group January 20, 2012 What are Functions? Introduction Uses Varieties Languages Full fledged SQL objects Many other database objects are implemented with them

More information

Python 2 and 3 compatibility testing via optional run-time type checking

Python 2 and 3 compatibility testing via optional run-time type checking Python 2 and 3 compatibility testing via optional run-time type checking Raoul-Gabriel Urma Work carried out during a Google internship & PhD https://github.com/google/pytypedecl Python 2 vs. Python 3

More information

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program. Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to

More information

Analog Documentation. Release 0.3.4. Fabian Büchler

Analog Documentation. Release 0.3.4. Fabian Büchler Analog Documentation Release 0.3.4 Fabian Büchler April 01, 2014 Contents 1 Contents 3 1.1 Quickstart................................................ 3 1.2 Analog API................................................

More information

Homework 1. Comp 140 Fall 2008

Homework 1. Comp 140 Fall 2008 Homework 1 Comp 140 Fall 2008 The Webster problem The devil made a proposition to Daniel Webster. The devil proposed paying Daniel for services in the following way:"on the first day, I will pay you $1,000

More information

Introduction to Computer Science I Spring 2014 Mid-term exam Solutions

Introduction to Computer Science I Spring 2014 Mid-term exam Solutions Introduction to Computer Science I Spring 2014 Mid-term exam Solutions 1. Question: Consider the following module of Python code... def thing_one (x): y = 0 if x == 1: y = x x = 2 if x == 2: y = -x x =

More information

LEARNING TO PROGRAM WITH PYTHON. Richard L. Halterman

LEARNING TO PROGRAM WITH PYTHON. Richard L. Halterman LEARNING TO PROGRAM WITH PYTHON Richard L. Halterman Copyright 2011 Richard L. Halterman. All rights reserved. i Contents 1 The Context of Software Development 1 1.1 Software............................................

More information

MATH10040 Chapter 2: Prime and relatively prime numbers

MATH10040 Chapter 2: Prime and relatively prime numbers MATH10040 Chapter 2: Prime and relatively prime numbers Recall the basic definition: 1. Prime numbers Definition 1.1. Recall that a positive integer is said to be prime if it has precisely two positive

More information

socketio Documentation

socketio Documentation socketio Documentation Release 0.1 Miguel Grinberg January 17, 2016 Contents 1 What is Socket.IO? 3 2 Getting Started 5 3 Rooms 7 4 Responses 9 5 Callbacks 11 6 Namespaces 13 7 Using a Message Queue 15

More information

Programming in Python. Basic information. Teaching. Administration Organisation Contents of the Course. Jarkko Toivonen. Overview of Python

Programming in Python. Basic information. Teaching. Administration Organisation Contents of the Course. Jarkko Toivonen. Overview of Python Programming in Python Jarkko Toivonen Department of Computer Science University of Helsinki September 18, 2009 Administration Organisation Contents of the Course Overview of Python Jarkko Toivonen (CS

More information

pyownet Documentation

pyownet Documentation pyownet Documentation Release 0.10.0 Stefano Miccoli March 30, 2016 Contents 1 Contents 3 1.1 Introduction............................................. 3 1.2 Installation..............................................

More information

Flask-SSO Documentation

Flask-SSO Documentation Flask-SSO Documentation Release 0.3.0 CERN July 30, 2015 Contents 1 Contents 3 1.1 Installation................................................ 3 1.2 Quickstart................................................

More information

CRASH COURSE PYTHON. Het begint met een idee

CRASH COURSE PYTHON. Het begint met een idee CRASH COURSE PYTHON nr. Het begint met een idee This talk Not a programming course For data analysts, who want to learn Python For optimizers, who are fed up with Matlab 2 Python Scripting language expensive

More information

What s Up with These Short Sale Buy Backs? http://www.youtube.com/watch?v=_ja6jehpr5k

What s Up with These Short Sale Buy Backs? http://www.youtube.com/watch?v=_ja6jehpr5k What s Up with These Short Sale Buy Backs? http://www.youtube.com/watch?v=_ja6jehpr5k DALE: Good afternoon. Today s topic of discussion is going to be going over the short sale lease back and short sale

More information