Context-Oriented Programming with Python

Size: px
Start display at page:

Download "Context-Oriented Programming with Python"

Transcription

1 Context-Oriented Programming with Python Martin v. Löwis Hasso-Plattner-Institut an der Universität Potsdam

2 Agenda Meta-Programming Example: HTTP User-Agent COP Syntax Implicit Layer Activation Django 2

3 Meta-Programming

4 Introspection and Reflection in Python Everything is an object classes/types (Python s class/type dichotomy) functions, bound and unbound methods code objects Implicit attributes for reflection: o. class (also: type(o)), for arbitrary objects o. dict, for arbitrary objects C. name, for classes and functions C. bases, for classes f.func_code, for functions Using standard container types dict is a dictionary bases is a tuple 4

5 Modifying the Program Creating new program elements: call the meta-type types.functiontype(code_objects, globals_dictionary) types.codetype(argcount, nlocals, stacksize, flags, codestring, names, varnames, filename, name, firstlineno, lnotab) type(name, bases, dict) # a.k.a. types.typetype Adding to and deleting from classes: modify classes dict Changing inheritance hierarchy: modify bases Adding to and deleting from objects: modify dict Changing the type of an object: assign to class 5

6 Protocols Indexed access (o[k]): o. getitem (k), o. setitem (k,v) Field access (o.a): o. getattr (a), o. setattr (o, a, v) also getattribute Iteration (for e in o:): o. iter (), then i.next() Call (o(args)): o. call (args) Hooks for instance creation: new and init... 6

7 Meta-Classes Standard meta-class: type (new-style classes) also: types.classtype, for old-style classes Meta-class usage on class definition: metaclass attribute in the class metaclass attribute in the module defining the class meta-class of the first base class new-style classes inherit from object, which is a new-style class 7

8 Decorators Decorator: Annotation on def bar(arguments): def foobar(more_arguments): body Operational semantics: Decorators must be callable bar = foo(bar) foobar = baz(arguments)(foobar) Various use cases: Declaration of static and class methods synchronized, logged, memoized,... functions 8

9 COP Example: User-Agent

10 HTTP Libraries httplib: Protocol implementation (full access to all protocol elements Little default behaviour (default: HTTP/1.1, Host:, Accept-Encoding:) def get1(): print "Using httplib" import httplib conn = httplib.httpsconnection(' #conn.set_debuglevel(1) conn.request('get', '/env') r = conn.getresponse() filter_response(r) 10

11 HTTP Libraries (2) urllib, urllib2: general URL access automatically sets User-Agent to Python-urllib/2.5 def get2(): print "Using urllib" import urllib2 f = urllib2.urlopen(' filter_response(f) def filter_response(f): for line in f.read().splitlines(): if line.find("user_agent")!= -1: print line return print "No user-agent found" 11

12 Using Method Layers with statement: automatic enter/leave semantics from useragent import HTTPUserAgent with HTTPUserAgent("WebCOP"): print "Using useragent layer" get1() get2() Importing useragent module automatically defines the layer and the layered methods Disabling layers from layers import Disabled with Disabled(Layer): code 12

13 Defining Layers Inherit from class Layer Class can have arbitrary methods, instance variables, etc class HTTPUserAgent(layers.Layer): def init (self, agent): self.agent = agent 13

14 Defining Layered Methods Inherit a class (with arbitrary name) from both the layer and the class to augment Define methods with the same name as the original methods Each method has automatic second parameter "context" (after self, before explicit method parameters) Decorate each method with either before, after, or instead Context: Object indicating the layer activation.layer: reference to the layer object.result: result of the original method (for after-methods).proceed: callable object denoting the continuation to the original method (or the next layer) 14

15 class HTTPConnection(HTTPUserAgent, httplib.httpconnection): # Always add a User-Agent def endheaders(self, context): with layers.disabled(httpuseragent): self.putheader("user-agent", context.layer.agent) # suppress other User-Agent headers def putheader(self, context, header, value): if header.lower() == 'user-agent': return return context.proceed(header, value) 15

16 Context-L Layer definition: Layers are classes access to layer instance's state through 'find-layer (only?) Layered methods and functions Layered class: may add layer-specific slots Layer Activation: explicit nested explicit deactivation 16

17 Comparing PyContext with Context-L Layer definition: Layers are classes Layer activation operates on instances Layered methods: put methods in class block no intuitive syntax for putting methods outside of classes method definitions refer to layer classes Layered functions: not supported yet Layered classes: not necessary Layered methods can add any slots they like Layer activation: both explicit and implicit 17

18 Implicit Activation

19 Context 19

20 Context State and history of the environment often not directly observable to a computer who is the current user? what is the temperature outside? what piece of code called this method? 19

21 Context State and history of the environment often not directly observable to a computer who is the current user? what is the temperature outside? what piece of code called this method? Sensor: device to observe context os.getuid(), os.environ["remote_user"] pymetar.reportfetcher("lszb")...gettemperaturecelsius() inspect.currentframe(1).f_code.co_filename 19

22 Context State and history of the environment often not directly observable to a computer who is the current user? what is the temperature outside? what piece of code called this method? Sensor: device to observe context os.getuid(), os.environ["remote_user"] pymetar.reportfetcher("lszb")...gettemperaturecelsius() inspect.currentframe(1).f_code.co_filename Condition: predicate on the context should a certain algorithm be executed? 19

23 Context-Awareness Selection of algorithm depending on conditions target of behavior layers not necessarily just on methods More generally: behavior is function of sensor readings control systems: context is input to formula part of context is index into some data structure (user name, object number, database transaction) currently not supported in COP 20

24 Conditions in PyContext Activation of layer depends on condition (predicate) predicate given as imperatively-defined function When to evaluate the predicate? whenever it changes? not feasible Solution: at method invocation After predicate evaluation, layer is activated just for the period Need to keep global list of layer instances whose conditions need checking Composition semantics: how to combine multiple layered methods? Solution: at activation time, the layered method conceptually replaced the original method multiple implicit layers: activate by "precedence", else in registration order 21

25 Demo: Configuration Files Assumption: Application reads configuration file at start up, then runs Context-orientation: changes to the configuration file should be taken into account Sensors: 1. Determination of change: look at modification time 2. Detection of change: multiple sensors, OS dependent Time-triggered checking (alarm(2), SIGALRM) Explicit signal by operator (SIGHUP) File-system change notifications Check on every method invocation use alarm mechanism for demo (check every 5 seconds) 22

26 class FileWatcher(Layer): all_instances = [] def init (self, filename):... def read(self): self.mtime = os.stat(filename).st_mtime self.signalled = False def signal(self): if self.mtime < os.stat(filename).st_mtime: self.signalled = True def active(self): return self.signalled def signalled(sig, frame): for obj in FileWatcher.all_instances: obj.signal() signal.alarm(10) signal.signal(signal.sigalrm, signalled) signal.alarm(10) 23

27 class AppExtension(FileWatcher, def do_msg(self, context): if context.layer.filename!= self.confname: # It's not our configuration file that changed return # update configuration self.read_conf() # deactivate layer context.layer.read() 24

28 Django

29 Overview Web framework O-R-Mapper HTML templating engine Webapp component framework HTTP server Webapp packaging and deployment 26

30 Context in Django: Server-originated ("System") context Configuration files: settings.py Database connection List of installed applications (and various plugins) change will automatically cause server reset Configuration files: URL space configuration mapping from URL regexes to Python functions (callables) re-read on every request? Model-View (applications) re-read on every request? need explicit synchronization with database schema 27

31 Context in Django: Request Context During processing, a HTTPRequest object is passed along Template engine has explicit notion of Context object context variables can be read in the template Middleware: Configurable software layers that each request goes through, affecting overall behaviour: sessions caching decorators to specify whether to cache, and how long transactions decorators for autocommit, commit_on_success, commit_manually 28

32 Further work Study Django implementation Try to identify places in the Django code or Django applications where COP could be applied Write paper 29

Context-Oriented Programming: Beyond Layers

Context-Oriented Programming: Beyond Layers Context-Oriented Programming: Beyond Layers Martin von Löwis 1 Marcus Denker 2 Oscar Nierstrasz 2 1 Operating Systems and Middleware Group Hasso-Plattner-Institute at University of Potsdam, Germany http://www.dcl.hpi.uni-potsdam.de

More information

Announcements. Homework 1 due Monday 10/12 (today) Homework 2 released next Monday 10/19 is due 11/2

Announcements. Homework 1 due Monday 10/12 (today) Homework 2 released next Monday 10/19 is due 11/2 61A Extra Lecture 6 Announcements Homework 1 due Monday 10/12 (today) Homework 2 released next Monday 10/19 is due 11/2 Homework 3 is to complete an extension to Project 4 Due at the same time as Project

More information

CSC326 Meta Programming i. CSC326 Meta Programming

CSC326 Meta Programming i. CSC326 Meta Programming i CSC326 Meta Programming ii REVISION HISTORY NUMBER DATE DESCRIPTION NAME 1.0 2011-09 JZ iii Contents 1 Agenda 1 2 Class Factory 1 3 Meta Class 1 4 Decorator 2 5 Misuse of Decorators 3 6 Using Decorators

More information

61A Lecture 16. Wednesday, October 5

61A Lecture 16. Wednesday, October 5 61A Lecture 16 Wednesday, October 5 Policy Changes Based on the Survey Homework can now be completed in pairs, if you wish. Every individual should still submit his/her own homework Please write your partner's

More information

features of Python 1.5, including the features earlier described in [2]. Section 2.6 summarizes what is new in Python The class and the class

features of Python 1.5, including the features earlier described in [2]. Section 2.6 summarizes what is new in Python The class and the class A note on reection in Python 1.5 Anders Andersen y AAndersen@ACM.Org March 13, 1998 Abstract This is a note on reection in Python 1.5. Both this and earlier versions of Python has an open implementation

More information

Lecture #15: Generic Functions and Expressivity. Last modified: Wed Mar 1 15:51: CS61A: Lecture #16 1

Lecture #15: Generic Functions and Expressivity. Last modified: Wed Mar 1 15:51: CS61A: Lecture #16 1 Lecture #15: Generic Functions and Expressivity Last modified: Wed Mar 1 15:51:48 2017 CS61A: Lecture #16 1 Consider the function find: Generic Programming def find(l, x, k): """Return the index in L of

More information

PYTHON CONTENT NOTE: Almost every task is explained with an example

PYTHON CONTENT NOTE: Almost every task is explained with an example PYTHON CONTENT NOTE: Almost every task is explained with an example Introduction: 1. What is a script and program? 2. Difference between scripting and programming languages? 3. What is Python? 4. Characteristics

More information

django-slim Documentation

django-slim Documentation django-slim Documentation Release 0.5 Artur Barseghyan December 24, 2013 Contents i ii django-slim Contents 1 2 Contents CHAPTER 1 Description Simple implementation of multi-lingual

More information

1 Decorators. 2 Descriptors. 3 Static Variables. 4 Anonymous Classes. Sandeep Sadanandan (TU, Munich) Python For Fine Programmers July 13, / 19

1 Decorators. 2 Descriptors. 3 Static Variables. 4 Anonymous Classes. Sandeep Sadanandan (TU, Munich) Python For Fine Programmers July 13, / 19 1 Decorators 2 Descriptors 3 Static Variables 4 Anonymous Classes Sandeep Sadanandan (TU, Munich) Python For Fine Programmers July 13, 2009 1 / 19 Decorator Pattern In object-oriented programming, the

More information

CSE : Python Programming. Decorators. Announcements. The decorator pattern. The decorator pattern. The decorator pattern

CSE : Python Programming. Decorators. Announcements. The decorator pattern. The decorator pattern. The decorator pattern CSE 399-004: Python Programming Lecture 12: Decorators April 9, 200 http://www.seas.upenn.edu/~cse39904/ Announcements Projects (code and documentation) are due: April 20, 200 at pm There will be informal

More information

Course Title: Python + Django for Web Application

Course Title: Python + Django for Web Application Course Title: Python + Django for Web Application Duration: 6 days Introduction This course offer Python + Django framework ( MTV ) training with hands on session using Eclipse+Pydev Environment. Python

More information

CNRS ANF PYTHON Objects everywhere

CNRS ANF PYTHON Objects everywhere CNRS ANF PYTHON Objects everywhere Marc Poinot Numerical Simulation Dept. Outline Python Object oriented features Basic OO concepts syntax More on Python classes multiple inheritance reuse introspection

More information

ECE 364 Software Engineering Tools Laboratory. Lecture 7 Python: Object Oriented Programming

ECE 364 Software Engineering Tools Laboratory. Lecture 7 Python: Object Oriented Programming ECE 364 Software Engineering Tools Laboratory Lecture 7 Python: Object Oriented Programming 1 Lecture Summary Object Oriented Programming Concepts Object Oriented Programming in Python 2 Object Oriented

More information

silk Documentation Release 0.3 Michael Ford

silk Documentation Release 0.3 Michael Ford silk Documentation Release 0.3 Michael Ford September 20, 2015 Contents 1 Quick Start 1 1.1 Other Installation Options........................................ 1 2 Profiling 3 2.1 Decorator.................................................

More information

Iterators and Generators

Iterators and Generators Iterators and Generators Alex Martelli AB Strakt 1 This Tutorial s Audience You have a good base knowledge of Python 2.* (say, 2.0 or 2.1) You may have no knowledge of iterators, generators, other 2.2

More information

Chapter 11 Object and Object- Relational Databases

Chapter 11 Object and Object- Relational Databases Chapter 11 Object and Object- Relational Databases Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11 Outline Overview of Object Database Concepts Object-Relational

More information

Context-Awareness and Adaptation in Distributed Event-Based Systems

Context-Awareness and Adaptation in Distributed Event-Based Systems Context-Awareness and Adaptation in Distributed Event-Based Systems Eduardo S. Barrenechea, Paulo S. C. Alencar, Rolando Blanco, Don Cowan David R. Cheriton School of Computer Science University of Waterloo

More information

Fun with Python Descriptors

Fun with Python Descriptors Fun with Python Descriptors Author: Jeff Rush Date: 2006-11-25 include directive disabled... include:: Overview What are descriptors? Implementation: attribute watcher Implementation: property()

More information

Python Metaclasses: Who? Why? When?

Python Metaclasses: Who? Why? When? Python Metaclasses: Who? Why? When? [Metaclasses] are deeper magic than 99% of users should ever worry about. If you wonder whether you need them, you don't (the people who actually need them know with

More information

Software Development Python (Part B)

Software Development Python (Part B) Software Development Python (Part B) Davide Balzarotti Eurecom 1 List Comprehension It is a short way to construct a list based on the content of other existing lists Efficient Elegant Concise List comprehensions

More information

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division CS 164 Spring 2005 P. N. Hilfinger Project #2: Static Analyzer for Pyth Due: Wednesday, 6 April

More information

pygtrie Release Jul 03, 2017

pygtrie Release Jul 03, 2017 pygtrie Release Jul 03, 2017 Contents 1 Features 3 2 Installation 5 3 Upgrading from 0.9.x 7 4 Trie classes 9 5 PrefixSet class 19 6 Version History 21 Python Module Index 23 i ii Implementation of a

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Chapter 12 Outline Overview of Object Database Concepts Object-Relational Features Object Database Extensions to SQL ODMG Object Model and the Object Definition Language ODL Object Database Conceptual

More information

Python A Technical Introduction. James Heliotis Rochester Institute of Technology December, 2009

Python A Technical Introduction. James Heliotis Rochester Institute of Technology December, 2009 Python A Technical Introduction James Heliotis Rochester Institute of Technology December, 2009 Background & Overview Beginnings Developed by Guido Van Rossum, BDFL, in 1990 (Guido is a Monty Python fan.)

More information

django-revproxy Documentation

django-revproxy Documentation django-revproxy Documentation Release 0.9.14 Sergio Oliveira Jun 30, 2017 Contents 1 Features 3 2 Dependencies 5 3 Install 7 4 Contents: 9 4.1 Introduction...............................................

More information

Django-CSP Documentation

Django-CSP Documentation Django-CSP Documentation Release 3.0 James Socol, Mozilla September 06, 2016 Contents 1 Installing django-csp 3 2 Configuring django-csp 5 2.1 Policy Settings..............................................

More information

Index. Cache, 20 Callables, 185 call () method, 290 chain() function, 41 Classes attributes descriptors, 145 properties, 143

Index. Cache, 20 Callables, 185 call () method, 290 chain() function, 41 Classes attributes descriptors, 145 properties, 143 Index A add_column() method, 284 add() method, 44 addtypeequalityfunc() method, 253 Affero General Public License (AGPL), 260 American Standard Code for Information Interchange (ASCII), 218 219 and operator,

More information

CS61A Lecture 21. Amir Kamil UC Berkeley March 11, 2013

CS61A Lecture 21. Amir Kamil UC Berkeley March 11, 2013 CS61A Lecture 21 Amir Kamil UC Berkeley March 11, 2013 Announcements HW7 due on Wednesday Ants project out Looking Up Names Name expressions look up names in the environment Dot expressions look

More information

Kaiso Documentation. Release 0.1-dev. onefinestay

Kaiso Documentation. Release 0.1-dev. onefinestay Kaiso Documentation Release 0.1-dev onefinestay Sep 27, 2017 Contents 1 Neo4j visualization style 3 2 Contents 5 2.1 API Reference.............................................. 5 3 Indices and tables

More information

alphafilter Documentation

alphafilter Documentation alphafilter Documentation Release 0.6 coordt September 09, 2013 CONTENTS i ii alphafilter Documentation, Release 0.6 Contents: CONTENTS 1 alphafilter Documentation, Release 0.6 2 CONTENTS CHAPTER ONE

More information

Security Regression. Addressing Security Regression by Unit Testing. Christopher

Security Regression. Addressing Security Regression by Unit Testing. Christopher Security Regression Addressing Security Regression by Unit Testing Christopher Grayson @_lavalamp Introduction WHOAMI ATL Web development Academic researcher Haxin all the things (but I rlllly like networks)

More information

Lecture #16: Generic Functions and Expressivity. Last modified: Fri Feb 26 19:16: CS61A: Lecture #16 1

Lecture #16: Generic Functions and Expressivity. Last modified: Fri Feb 26 19:16: CS61A: Lecture #16 1 Lecture #16: Generic Functions and Expressivity Last modified: Fri Feb 26 19:16:38 2016 CS61A: Lecture #16 1 Consider the function find: Generic Programming def find(l, x, k): """Return the index in L

More information

Context-oriented Programming. Pascal Costanza (Vrije Universiteit Brussel, Belgium) Robert Hirschfeld (Hasso-Plattner-Institut, Potsdam, Germany)

Context-oriented Programming. Pascal Costanza (Vrije Universiteit Brussel, Belgium) Robert Hirschfeld (Hasso-Plattner-Institut, Potsdam, Germany) Context-oriented Programming Pascal Costanza (Vrije Universiteit Brussel, Belgium) Robert Hirschfeld (Hasso-Plattner-Institut, Potsdam, Germany) Programs are too static! Mobile devices Software agents

More information

Objects CHAPTER 6. FIGURE 1. Concrete syntax for the P 3 subset of Python. (In addition to that of P 2.)

Objects CHAPTER 6. FIGURE 1. Concrete syntax for the P 3 subset of Python. (In addition to that of P 2.) CHAPTER 6 Objects The main ideas for this chapter are: objects and classes: objects are values that bundle together some data (attributes) and some functions (methods). Classes are values that describe

More information

pysharedutils Documentation

pysharedutils Documentation pysharedutils Documentation Release 0.5.0 Joel James August 07, 2017 Contents 1 pysharedutils 1 2 Indices and tables 13 i ii CHAPTER 1 pysharedutils pysharedutils is a convenient utility module which

More information

Lecture no

Lecture no Advanced Algorithms and Computational Models (module A) Lecture no. 3 29-09-2014 Giacomo Fiumara giacomo.fiumara@unime.it 2014-2015 1 / 28 Expressions, Operators and Precedence Sequence Operators The following

More information

Design issues for objectoriented. languages. Objects-only "pure" language vs mixed. Are subclasses subtypes of the superclass?

Design issues for objectoriented. languages. Objects-only pure language vs mixed. Are subclasses subtypes of the superclass? Encapsulation Encapsulation grouping of subprograms and the data they manipulate Information hiding abstract data types type definition is hidden from the user variables of the type can be declared variables

More information

Some notes about Event-B and Rodin

Some notes about Event-B and Rodin Some notes about Event-B and Rodin Résumé This document briefly presents the language event-b and the tool Rodin. For a comprehensive presentation, refer to the event-b page http://www.event-b.org/, the

More information

All-Singing All-Dancing Python Bytecode Larry Hastings EuroPython 2013 July 2, 2013

All-Singing All-Dancing Python Bytecode Larry Hastings EuroPython 2013 July 2, 2013 All-Singing All-Dancing Python Bytecode Larry Hastings larry@hastings.org EuroPython 2013 July 2, 2013 Introduction Intermediate CPython 3.3.0 100% roughly applicable elsewhere What Is Bytecode? Opcodes

More information

The WSGI Reference Library

The WSGI Reference Library The WSGI Reference Library Release 0.2 Phillip J. Eby October 4, 2010 Email: pje@telecommunity.com Abstract The Web Server Gateway Interface (WSGI) is a standard interface between web server software and

More information

Meta Classes. Chapter 4

Meta Classes. Chapter 4 Chapter 4 Meta Classes Python classes are also objects, with the particularity that these can create other objects (their instances). Since classes are objects, we can assign them to variables, copy them,

More information

Sage Reference Manual: Python technicalities

Sage Reference Manual: Python technicalities Sage Reference Manual: Python technicalities Release 8.1 The Sage Development Team Dec 09, 2017 CONTENTS 1 Various functions to debug Python internals 3 2 Variants of getattr() 5 3 Metaclasses for Cython

More information

A Comparison of Context-oriented Programming Languages

A Comparison of Context-oriented Programming Languages A Comparison of Context-oriented Programming Languages Malte Appeltauer Robert Hirschfeld Michael Haupt Jens Lincke Michael Perscheid Hasso-Plattner-Institute University of Potsdam, Germany {firstname.lastname}@hpi.uni-potsdam.de

More information

A Framework for Creating Distributed GUI Applications

A Framework for Creating Distributed GUI Applications A Framework for Creating Distributed GUI Applications Master s Project Report Derek Snyder May 15, 2006 Advisor: John Jannotti Introduction Creating distributed graphical user interface (GUI) applications

More information

webkitpony Documentation

webkitpony Documentation webkitpony Documentation Release 0.1 Toni Michel May 24, 2014 Contents 1 Motivation 3 2 Goal 5 3 Understanding webkitpony 7 3.1 Understanding webkitpony........................................ 7 3.2 The

More information

Lecture 16: Static Semantics Overview 1

Lecture 16: Static Semantics Overview 1 Lecture 16: 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

Descriptor HowTo Guide Release 3.3.3

Descriptor HowTo Guide Release 3.3.3 Descriptor HowTo Guide Release 3.3.3 Guido van Rossum Fred L. Drake, Jr., editor November 17, 2013 Python Software Foundation Email: docs@python.org Contents 1 Abstract ii 2 Definition and Introduction

More information

Seshat Documentation. Release Joshua P Ashby

Seshat Documentation. Release Joshua P Ashby Seshat Documentation Release 1.0.0 Joshua P Ashby Apr 05, 2017 Contents 1 A Few Minor Warnings 3 2 Quick Start 5 2.1 Contributing............................................... 5 2.2 Doc Contents...............................................

More information

Final thoughts on functions F E B 2 5 T H

Final thoughts on functions F E B 2 5 T H Final thoughts on functions F E B 2 5 T H Ordering functions in your code Will the following code work? Here the function is defined after the main program that is calling it. print foo() def foo(): return

More information

django-data-migration Documentation

django-data-migration Documentation django-data-migration Documentation Release 0.2.1 Philipp Böhm Sep 27, 2017 Contents 1 Contents: 3 1.1 Installing................................................. 3 1.2 Writing Migrations............................................

More information

Static Analysis of Dynamically Typed Languages made Easy

Static Analysis of Dynamically Typed Languages made Easy Static Analysis of Dynamically Typed Languages made Easy Yin Wang School of Informatics and Computing Indiana University Overview Work done as two internships at Google (2009 summer and 2010 summer) Motivation:

More information

Advanced Python Subjects. By Imri Goldberg plnnr.com

Advanced Python Subjects. By Imri Goldberg   plnnr.com Advanced Python Subjects By Imri Goldberg www.algorithm.co.il plnnr.com Introduction Many people I know come to Python from C/C++. Including me! They bring with them many unpythonic idioms: inheritance

More information

Module 3 Web Component

Module 3 Web Component Module 3 Component Model Objectives Describe the role of web components in a Java EE application Define the HTTP request-response model Compare Java servlets and JSP components Describe the basic session

More information

Introduction to Python programming, II

Introduction to Python programming, II Grid Computing Competence Center Introduction to Python programming, II Riccardo Murri Grid Computing Competence Center, Organisch-Chemisches Institut, University of Zurich Nov. 16, 2011 Today s class

More information

Customizing the Welcome Page with an Overview over the last Changes and the Taxonomies

Customizing the Welcome Page with an Overview over the last Changes and the Taxonomies Customizing the Welcome Page with an Overview over the last Changes and the Taxonomies Customizing the Welcome Page with an Overview over the last Changes and the Taxonomies The following tutorial gives

More information

Configuring and Using Osmosis Platform

Configuring and Using Osmosis Platform Configuring and Using Osmosis Platform Index 1. Registration 2. Login 3. Device Creation 4. Node Creation 5. Sending Data from REST Client 6. Checking data received 7. Sending Data from Device 8. Define

More information

Outline. 1 Introduction. 2 Meta-Classes in Python. 3 Meta-Classes vs. Traditional OOP. Meta-Classes. Guy Wiener. Introduction. Meta-Classes in Python

Outline. 1 Introduction. 2 Meta-Classes in Python. 3 Meta-Classes vs. Traditional OOP. Meta-Classes. Guy Wiener. Introduction. Meta-Classes in Python Outline 1 2 3 Outline 1 2 3 What is Meta-Programming? Definition Meta-Program A program that: One of its inputs is a program (possibly itself) Its output is a program Meta-Programs Nowadays Compilers Code

More information

Transactions for web developers

Transactions for web developers Transactions for web developers Aymeric Augustin - @aymericaugustin DjangoCon Europe - May 17th, 2013 1 Transaction management tools are often made to seem like a black art. Christophe Pettus (2011) Life

More information

Django with Python Course Catalog

Django with Python Course Catalog Django with Python Course Catalog Enhance Your Contribution to the Business, Earn Industry-recognized Accreditations, and Develop Skills that Help You Advance in Your Career March 2018 www.iotintercon.com

More information

Lecture 5. Defining Functions

Lecture 5. Defining Functions Lecture 5 Defining Functions Announcements for this Lecture Last Call Quiz: About the Course Take it by tomorrow Also remember the survey Readings Sections 3.5 3.3 today Also 6.-6.4 See online readings

More information

Positional, keyword and default arguments

Positional, keyword and default arguments O More on Python n O Functions n Positional, keyword and default arguments in repl: >>> def func(fst, snd, default="best!"):... print(fst, snd, default)... >>> func(snd='is', fst='python') ('Python', 'is',

More information

20.5. urllib Open arbitrary resources by URL

20.5. urllib Open arbitrary resources by URL 1 of 9 01/25/2012 11:19 AM 20.5. urllib Open arbitrary resources by URL Note: The urllib module has been split into parts and renamed in Python 3.0 to urllib.request, urllib.parse, and urllib.error. The

More information

WHY YOU DON'T NEED DESIGN PATTERNS IN PYTHON? EuroPython 2017

WHY YOU DON'T NEED DESIGN PATTERNS IN PYTHON? EuroPython 2017 WHY YOU DON'T NEED DESIGN PATTERNS IN PYTHON? EuroPython 2017 EVERYTHING STARTS WITH A STORY... Zen of Python! STORY OF A PYTHON DEVELOPER TDD FOR THE WIN!!! Readability first! Thousands+ lines of code

More information

django-intercom Documentation

django-intercom Documentation django-intercom Documentation Release 0.0.12 Ken Cochrane February 01, 2016 Contents 1 Installation 3 2 Usage 5 3 Enable Secure Mode 7 4 Intercom Inbox 9 5 Custom Data 11 6 Settings 13 6.1 INTERCOM_APPID...........................................

More information

Technology modeling. Ralf Lämmel Software Languages Team University of Koblenz-Landau

Technology modeling. Ralf Lämmel Software Languages Team University of Koblenz-Landau Technology modeling Ralf Lämmel Software Languages Team University of Koblenz-Landau Technologies are at the heart of software development. Let s model them for understanding. 1 Different kinds of software

More information

What's New in Python 2.2

What's New in Python 2.2 What's New in Python 2.2 LinuxWorld - New York City - January 2002 Guido van Rossum Director of PythonLabs at Zope Corporation guido@python.org guido@zope.com Overview Appetizers Nested Scopes Int/Long

More information

Creational. Structural

Creational. Structural Fitness for Future of Design Patterns & Architectural Styles Design patterns are difficult to teach, so we conducted a class collaboration where we all researched and reported on a variety of design patterns

More information

A Class to Manage Large Ensembles and Batch Execution in Python

A Class to Manage Large Ensembles and Batch Execution in Python Introduction Ensemble Class Argument Expansion A Class to Manage Large Ensembles and Batch Execution in Python PyCon Canada Andre R. Erler November 12 th, 2016 Introduction Ensemble Class Argument Expansion

More information

Configuring Cisco IOS CNS Agents

Configuring Cisco IOS CNS Agents CHAPTER 4 This chapter describes how to configure the Cisco IOS CNS agents on the Catalyst 2960 switch. Note For complete configuration information for the Cisco Configuration Engine, see this URL on Cisco.com

More information

djangotribune Documentation

djangotribune Documentation djangotribune Documentation Release 0.7.9 David THENON Nov 05, 2017 Contents 1 Features 3 2 Links 5 2.1 Contents................................................. 5 2.1.1 Install..............................................

More information

A Small Interpreted Language

A Small Interpreted Language A Small Interpreted Language What would you need to build a small computing language based on mathematical principles? The language should be simple, Turing equivalent (i.e.: it can compute anything that

More information

Session 8. Reading and Reference. en.wikipedia.org/wiki/list_of_http_headers. en.wikipedia.org/wiki/http_status_codes

Session 8. Reading and Reference. en.wikipedia.org/wiki/list_of_http_headers. en.wikipedia.org/wiki/http_status_codes Session 8 Deployment Descriptor 1 Reading Reading and Reference en.wikipedia.org/wiki/http Reference http headers en.wikipedia.org/wiki/list_of_http_headers http status codes en.wikipedia.org/wiki/_status_codes

More information

What is a Class Diagram? A diagram that shows a set of classes, interfaces, and collaborations and their relationships

What is a Class Diagram? A diagram that shows a set of classes, interfaces, and collaborations and their relationships Class Diagram What is a Class Diagram? A diagram that shows a set of classes, interfaces, and collaborations and their relationships Why do we need Class Diagram? Focus on the conceptual and specification

More information

What is a Class Diagram? Class Diagram. Why do we need Class Diagram? Class - Notation. Class - Semantic 04/11/51

What is a Class Diagram? Class Diagram. Why do we need Class Diagram? Class - Notation. Class - Semantic 04/11/51 What is a Class Diagram? Class Diagram A diagram that shows a set of classes, interfaces, and collaborations and their relationships Why do we need Class Diagram? Focus on the conceptual and specification

More information

Extending Jython. with SIM, SPARQL and SQL

Extending Jython. with SIM, SPARQL and SQL Extending Jython with SIM, SPARQL and SQL 1 Outline of topics Interesting features of Python and Jython Relational and semantic data models and query languages, triple stores, RDF Extending the Jython

More information

django-conduit Documentation

django-conduit Documentation django-conduit Documentation Release 0.0.1 Alec Koumjian Apr 24, 2017 Contents 1 Why Use Django-Conduit? 3 2 Table of Contents 5 2.1 Filtering and Ordering.......................................... 5

More information

Object Oriented Programming in Python 3

Object Oriented Programming in Python 3 Object Oriented Programming in Python 3 Objects Python 3 Objects play a central role in the Python data model All the types we ve seen until now are in-fact objects Numeric types, strings, lists, tuples,

More information

Babu Madhav Institute of Information Technology, UTU 2015

Babu Madhav Institute of Information Technology, UTU 2015 Five years Integrated M.Sc.(IT)(Semester 5) Question Bank 060010502:Programming in Python Unit-1:Introduction To Python Q-1 Answer the following Questions in short. 1. Which operator is used for slicing?

More information

About Python. Python Duration. Training Objectives. Training Pre - Requisites & Who Should Learn Python

About Python. Python Duration. Training Objectives. Training Pre - Requisites & Who Should Learn Python About Python Python course is a great introduction to both fundamental programming concepts and the Python programming language. By the end, you'll be familiar with Python syntax and you'll be able to

More information

Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming

Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming Nicolas Bettenburg 1 Universitaet des Saarlandes, D-66041 Saarbruecken, nicbet@studcs.uni-sb.de Abstract. As traditional

More information

Practical uses for. Function Annotations. Manuel Ceron

Practical uses for. Function Annotations. Manuel Ceron Practical uses for Function Annotations Manuel Ceron manuel.ceron@booking.com About me Colombian developer living in the Netherlands First time at EuroPython Programming Python for 10 years Currently working

More information

CS162 Week 4. Kyle Dewey. Sunday, February 3, 13

CS162 Week 4. Kyle Dewey. Sunday, February 3, 13 CS162 Week 4 Kyle Dewey Overview Reactive imperative programming refresher Rest of newcons What atomic is Implementation details Reactive Imperative Programming Refresher Basic Semantics Execute code in

More information

About the Tutorial. Audience. Prerequisites. Disclaimer & Copyright. TurboGears

About the Tutorial. Audience. Prerequisites. Disclaimer & Copyright. TurboGears About the Tutorial TurboGears is a Python web application framework, which consists of many modules. It is designed around the MVC architecture that are similar to Ruby on Rails or Struts. TurboGears are

More information

ExtraHop Rest API Guide

ExtraHop Rest API Guide ExtraHop Rest API Guide Version 5.0 Introduction to ExtraHop REST API The ExtraHop REST application programming interface (API) enables you to automate administration and configuration tasks on your ExtraHop

More information

ObjectStore and Objectivity/DB. Application Development Model of Persistence Advanced Features

ObjectStore and Objectivity/DB. Application Development Model of Persistence Advanced Features Object-Oriented Oi t ddatabases ObjectStore and Objectivity/DB Application Development Model of Persistence Advanced Features Persistence Strategies Persistence by inheritance persistence capabilities

More information

Harness the power of Python magic methods and lazy objects.

Harness the power of Python magic methods and lazy objects. Harness the power of Python magic methods and lazy objects. By Sep Dehpour Aug 2016 zepworks.com sep at zepworks.com https://github.com/seperman/redisworks Lazy Loading Defer initialization of an object

More information

iwiki Documentation Release 1.0 jch

iwiki Documentation Release 1.0 jch iwiki Documentation Release 1.0 jch January 31, 2014 Contents i ii Contents: Contents 1 2 Contents CHAPTER 1 Python 1.1 Python Core 1.1.1 Strings 1.1.2 Functions Argument Lists *args tuple/list **kwargs

More information

django-modern-rpc Documentation

django-modern-rpc Documentation django-modern-rpc Documentation Release 0.10.0 Antoine Lorence Dec 11, 2017 Table of Contents 1 What is RPC 1 2 What is django-modern-rpc 3 3 Requirements 5 4 Main features 7 5 Quick-start 9 5.1 Quick-start

More information

Table of Contents. Dive Into Python...1

Table of Contents. Dive Into Python...1 ...1 Chapter 1. Installing Python...2 1.1. Which Python is right for you?...2 1.2. Python on Windows...2 1.3. Python on Mac OS X...3 1.4. Python on Mac OS 9...5 1.5. Python on RedHat Linux...5 1.6. Python

More information

Enabling Embedded Systems to access Internet Resources

Enabling Embedded Systems to access Internet Resources Enabling Embedded Systems to access Internet Resources Embedded Internet Book www.embeddedinternet.org 2 Agenda : RATIONALE Web Services: INTRODUCTION HTTP Protocol: REVIEW HTTP Protocol Bindings Testing

More information

Quick housekeeping Last Two Homeworks Extra Credit for demoing project prototypes Reminder about Project Deadlines/specifics Class on April 12th Resul

Quick housekeeping Last Two Homeworks Extra Credit for demoing project prototypes Reminder about Project Deadlines/specifics Class on April 12th Resul CIS192 Python Programming Web Frameworks and Web APIs Harry Smith University of Pennsylvania March 29, 2016 Harry Smith (University of Pennsylvania) CIS 192 March 29, 2016 1 / 25 Quick housekeeping Last

More information

Python Interview Questions & Answers

Python Interview Questions & Answers Python Interview Questions & Answers Q 1: What is Python? Ans: Python is an interpreted, interactive, object-oriented programming language. It incorporates modules, exceptions, dynamic typing, very high

More information

Hello World in HLPSL. Turning ASCII protocol specifications into HLPSL

Hello World in HLPSL. Turning ASCII protocol specifications into HLPSL Hello World in HLPSL Turning ASCII protocol specifications into HLPSL Modeling with HLPSL HLPSL is a higher-level protocol specification language we can transform ASCII protocol specifications into HLPSL

More information

CIS192 Python Programming

CIS192 Python Programming CIS192 Python Programming Functional Programming Eric Kutschera University of Pennsylvania January 30, 2015 Eric Kutschera (University of Pennsylvania) CIS 192 January 30, 2015 1 / 31 Questions Homework

More information

PYTHON TRAINING COURSE CONTENT

PYTHON TRAINING COURSE CONTENT SECTION 1: INTRODUCTION What s python? Why do people use python? Some quotable quotes A python history lesson Advocacy news What s python good for? What s python not good for? The compulsory features list

More information

PTN-102 Python programming

PTN-102 Python programming PTN-102 Python programming COURSE DESCRIPTION Prerequisite: basic Linux/UNIX and programming skills. Delivery Method Instructor-led training (ILT) Duration Four days Course outline Chapter 1: Introduction

More information

Create web pages in HTML with a text editor, following the rules of XHTML syntax and using appropriate HTML tags Create a web page that includes

Create web pages in HTML with a text editor, following the rules of XHTML syntax and using appropriate HTML tags Create a web page that includes CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB By Hassan S. Shavarani UNIT2: MARKUP AND HTML 1 IN THIS UNIT YOU WILL LEARN THE FOLLOWING Create web pages in HTML with a text editor, following

More information

RedBarrel Documentation

RedBarrel Documentation RedBarrel Documentation Release 1.0 2011, Tarek Ziadé August 08, 2011 CONTENTS 1 What s RedBarrel? 3 1.1 Anatomy of a Web Service........................................ 3 1.2 The RBR DSL..............................................

More information

The Legion Mapping Interface

The Legion Mapping Interface The Legion Mapping Interface Mike Bauer 1 Philosophy Decouple specification from mapping Performance portability Expose all mapping (perf) decisions to Legion user Guessing is bad! Don t want to fight

More information

Large-Scale Networks

Large-Scale Networks Large-Scale Networks 3b Python for large-scale networks Dr Vincent Gramoli Senior lecturer School of Information Technologies The University of Sydney Page 1 Introduction Why Python? What to do with Python?

More information