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

Size: px
Start display at page:

Download "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"

Transcription

1 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 where we can access and alter the internal structures of language components. Python 1.5 takes this one step further making it even easier to adapt a reective programming model. These dynamic features of Python were one of the reasons for chosing it as the language used to implement an experimental reective middleware platform in the SUMO II project. We will in this note describe the open implementation in Python 1.5 and show how it can be used to achieve a reective programming model. The note also includes a description of our reection module for Python. 1 Introduction Python 1.4, which was the previous release of Python, was recognized as a good choice for a language implementing a experimental reective middleware platform in the SUMO II project [1]. All the dynamic features in the language made it possible to go behind the scene and inspect and change the behavior of the language components [2]. In the latest version of the language, version 1.5 1, these dynamic features have been developed even further. We will in this note try to describe how Python 1.5 can be used to adapt a reective programming model. Be aware that we are not talking about the Python interpreter itself as reective 2. We are focusing on a programming model with classes, objects (instances of classes) and its methods and attributes. We will rst describe the reective features of Python. We will then give some comments about how this can be used in our and related work. Add the end a short description of the Python module reection is attached. We will in the rest of this note talk about Python 1.5 when nothing else is specied. We will use the phrase `earlier versions' about version 1.4 and older. 2 The reective features in Python 1.5 Michael Papathomas describes reective features of earlier versions of Python in \Using Reection in Middleware Platforms" [2]. We will in this note try to describe all the reective Distributed Multimedia Research Group Report MPG-98-05, Lancaster University, UK. y This work was carried out while being a visiting researcher at the Lancaster University, UK. 1 Python version 1.5 is available at 2 A description of a reective interpreter for CLOS can be found in \The Art of the Metaobject Protocol" [3]. 1

2 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 hierarchy Each instance of a class (an object) has a class attribute which gives the class of this instance. However, types dened in C and other built in types do not have this class attribute. The bases attribute in each class is a tuple containing base classes (direct parent classes), and it can be used to inspect the inheritance hierarchy of a class. In Python 1.5 it is also possible to change the class of an instance at runtime. You just give the class attribute a new value and the instance has changed class. Michael Papathomas developed a neat C extension module called reect to implement this for earlier versions of Python. In Python 1.5 this module is no longer needed. 2.2 Attributes and methods The attributes of instances and classes are stored in dictionaries in Python. The class dictionary contains all attributes (and methods) dened for this particular class. Inherited attributes are not copied over to this dictionary. Instead, they are looked up dynamically when referred. The instance dictionary holds attributes assigned or changed after it is created. You may also say that the instance dictionary holds attributes that vary between dierent instances of a class. The dictionary of a class or an instance is available in its dict attribute. You can change, add and remove attributes from both classes and instances by directly accessing their dict attribute or by using the normal Python syntax. For instances can you even change the dictionary completely by assigning a new dictionary to the dict attribute. You can also add methods to a class using its dict attribute, but you have to remember that a class method needs a reference to the relevant instance as the rst argument (the self argument). Because of this self argument, there is no direct way to add methods to an instance. A workaround is however easy to implement. We can hold this information in an object and use the possibility in Python to call an object as a method if it has its call method dened. 2.3 Attribute access By providing the class methods getattr and setattr it is possible to control access to attributes in classes and instances in Python. If getattr is dened, it will be called whenever an attribute that does not exist in the instance or any of its classes is red. Normally this will give an undened-name error, but the getattr method will catch these. The setattr and delattr methods are triggered under the same conditions when you respectively try to assign a value to an attribute or delete an attribute. 2.4 The Don Beaudry and the metaclass hook In earlier versions of the Python interpreter there is something called the \Don Beaudry hook". This, which you still will nd in Python, is used to provide an alternate class 2

3 behavior to C extensions 3, allowing the Python class syntax to be used to dene other classlike entities. This has been used in the MESS [4] and the Extension Class [5] packages. The Don Beaudry hook can apply when the class creation syntax is used. It checks if the type of the base class is callable, and if so, it is called to create the new class. The Don Beaudry hook never applies when we are only using core Python, since the type of a core object is never callable. We can however notice that this gives us the possibility to control the creation of some special types of classes in a very powerfull way. In Python 1.5 another similar hook is introduced [6]. We have chosen to call this hook the \class metaclass hook" and it can also be applied when the class creation syntax is used (both hooks are \metaclass hooks" 4 ). The class metaclass hook checks if the base class has a class attribute. If so, an instance of the class given in the class attribute is created, and this instance will be the new class. So an instance has now become a class. The class in the class attribute will be referred to as the metaclass and the instance of this metaclass is a class. Confused? Well, be patient and we will soon show you some code. First, we have to take a closer look on what is happening when the class, also known as the instance of the metaclass, is created. So far have we only said that when the Don Beaudry hook or the class metaclass hook applies, either the type of the base class is called (for the Don Beaudry hook) or an instance of the class in the class attribute of the base class is created (for the class metaclass hook). Let us illustrate this with a simple class C: class C(D): 1 a = 1 2 b = "text" 3 This class has a base class D and two attributes a and b. If one of the hooks above applies, you can think of this as equivalent to C = creator('c', (D,), f'a': 1, 'b': "text"g) 1 where f'a': 1, 'b': 2g is the namespace of the class statement, (D,) is a tuple containing the base classes, 'C' is the name of the new class and creator is either the callable type of D (when the Don Beaudry hook is applied) or the class of the class attribute in D (when the class metaclass hook is applied). We will now concentrate on the class metaclass hook, since this is the most interesting hook in our use of Python. Since the the instance of the metaclass is created with the arguments shown above, we allready know about the arguments for the init method of the metaclass. Since this 5 new instance is going to act as a class, we also know the metaclass has to have a call method used when when someone makes a new instance of this class. This call method behaves like the init method in ordinary classes, except that it has to return something (an instance). Here is an example of a simple metaclass: class MyMetaClass: 1 def init (self, name, bases, namespace): 2 3 Classes, built-in-types and C extension types do not share a common behavior in Python. Built-in-types and C extension types can for example not be inherited. 4 I suggested this name for the new hook on the PSA (The Python Software Activity) mailing list, and Guido van Rossum replied \Yes, I think this is a perfect name (though it should apply equally to the C version and the Python version of the hook)". So we now use the term \metaclass hook" for both hooks and \class metaclass hook" for the new hook. 5 A call method of a class is applied when an instance of the class is called like a method. 3

4 self. name = name 3 self. bases = bases 4 self. namespace = namespace 5 def call (self): 6 return Instance(self) 7 This metaclass saves the information about a class when the class is created. We can now make a class which is an instance of the metaclass MyMetaClass. An example of such a class can be: class MyClass(BaseClass): 1 a = 1 2 b = "text" 3 BaseClass has to be a class that connects MyClass to MyMetaClass with the metaclass hook. The metaclass hook will apply if there is a class attribute in BaseClass. If this attribute is MyMetaClass MyClass will be created as an instance of of MyMetaClass. This can be translated to MyClass = BaseClass. class ('MyClass', (BaseClass,), f'a': 1, 'b': "text"g) 1 where BaseClass. class is MyMetaClass. Then what is BaseClass? It has to have a class attribute which is MyMetaClass, so we can simply make it a dummy instance of MyMetaClass: BaseClass = MyMetaClass('BaseClass', (), fg) 1 MyClass is an instance of MyMetaClass, and when we later create an instance of MyClass the call method of MyMetaClass will be called. This method will return an instance of the Instance class. The class attribute of MyClass and BaseClass is the same since both are an instance of MyMetaClass. However, MyClass and BaseClass are not equal, since they do not have the same name, base classes and namespace. Still confused? Another description and more examples of the use of this hook is available in Guido van Rossum's \Metaclasses in Python 1.5" essay [6]. 2.5 Other reective features of Python There is also other reective features in Python, for example concerning the namespace of modules. We have only concentrated on reection on classes and objects since we want to achieve reection at this level in the programming model. 2.6 What is new in Python 1.5? The possibility to change the value of the class attribute of an instance is new in Python 1.5. The same is the possibility to assign the dict attribute in an instance to a new dictionary. The class metaclass hook is also new in Python 1.5. There is also a lot of other interesting changes in Python, like a new regular expression module, a more ecient interpreter implementation, package support and so on, but none of this directly inuence the reective programming model and are therefore not discussed here. 4

5 3 What is in it for us? 3.1 A reective programming model The reective features in Python 1.5 made it easy to achieve a reective programming model at the object (and class) level. Appendix A describes an implementation of this programming model. 3.2 A reective middleware We have also started to investigate and implement a reective middleware platform based on this reective programming model. Some of the ideas and some of the work done are discussed in Gordon Blair's \Notes on Reective Middleware" [1] and in Michael Papathomas' \Using Reection in Middleware Platforms" [2]. Our approach is to have a functional level which consits of objects and bindings between objects, and a metalevel where non-functional aspects are taken into concern. This model has a lot common with the computational and then engineering viewpoints in the ODP reference model [7] but the reective approach gives you a strong tool to separate these concerns and alter the behavior through the metalevel. While you on the functional level only will see objects and bindings, you will on the metalevel nd capsules giving a location for objects, dierent scheduling policies for dierent needs, dierent bindings for dierent needs and so on. For example, you introduce explicit bindings and quality of service parameters by accessing the metalevel through the metaobject of an object. A further description and a more complete implementation of this approach are under development. 3.3 ATOM In ATOM [8, 9], a concurrent object-oriented programming model, one of the goals is to separate the concurrency mechanisms from the object-oriented mechanism. An implementation of this programming model has been done in Python. It is possible that a new implementation of ATOM could gain from taking a reective approach. The separation of concern for concurrency mechanisms and object-oriented mechanisms has a lot in common with the separation of concern in our middleware approach, and a similar approach where concurrency mechanisms is managed on the metalevel seems like a good idea. ATOM could also use the new metaclass hook when creating an active object class 6. In the current implementation you have to create an active object class by applying the function ActiveObject to a class that inherits from ActiveObjectSupport. In a new implementation the ActiveObjectSupport could trigger the metaclass hook and create the class without using the ActiveObject function (the ActiveObject function builds the necessary infrastructure for active objects in ATOM). 6 Active objects, or ATOM objects, is multi-threaded objects, where a new thread is created for each method call. Other threads can also exists for the execution of internal activities. 5

6 4 A note at the end My hope is that you now are ready to play with this, so I have attached a note at the end describing where to nd the software and some documentation. Python and a lot of more Python related stu is available from the Python home: On this site will you nd Guido van Rossum's essay on metaclasses [6] and also references to other related documents like [4] and [5]. Another good source for software and documentation is the Python Starship: 7 This is also the place where the reection module and this note is available from: References [1] G. Blair, \Notes on reective midleware," tech. rep., Department of Computing, Lancaster University, [2] M. Papathomas, \Using reection in middleware platforms," tech. rep., Computing Department, Lancaster University, June Draft. [3] G. Kiczales, J. des Rivieres, and D. G. Bobrow, The Art of the Metaobject Protocol. The MIT Press, [4] D. Beaudry, MESS Tutorial, [5] J. Fulton, \Extension classes, Python extension types become classes," tech. rep., Digital Creations, [6] G. van Rossum, \Metaclasses in Python 1.5," essay, Corporation for National Research Initiatives, [7] K. Raymond, \Reference model of open distributed processing (RM-ODP): Introduction," tech. rep., CRC fo Distributed System Technology, Centre for Information Technology Research, University of Queensland, [8] M. Papathomas and A. Andersen, \Concurrent object-orieted programming in Python with ATOM," in The Sixth International Python Conference, (San Jose, California), pp. 77{87, October [9] M. Papathomas, \ATOM: An active object model for enhancing reuse in the development of concurrent software," Research Report 963-I-LSR-2, IMAG-LSR, Grenoble, France, November The Python Starship will probably change its URL to in the near future. 6

7 A The Python reection module The Python reection module exposes and extends the reective features in Python. It provide reection at the object level, meaning that you can inspect, modify and extend objects. The module also includes some functions to manipulate classes (inspectclass, addmethodclass and delmethodclass), but we have focused on the possibility to manipulates objects. The functions provided to manipulate objects are: inspectobject inspects the given object and return a dictionary describing it, addmethodobject adds a new method to an object, delmethodobject deletes a method from an object, addpremethodobject adds a pre-method to a method in an object, delpremethodsobject deletes pre-methods from a method in an object, addpostmethodobject adds a post-method to a method in an object, delpostmethodsobject deletes post-methods from a method in an object, and changeclassobject changes the class of an object. These features are either provided by manipulating the object itself directly or through a metaobject of the object. If the object have a metaobject (accessible through the meta attribute of the object), the metaobject is in control of the object. If there is no metaobject for the object, the manipulation is done directly on the object it self. This module provides two metaobjects, BasicMeta and PlainMeta. BasicMeta implements the object manipulation by directly manipulating the object itself. PlainMeta does not change the object itself, but builds new structures around it. These simple classes could easily be extended or changed through inheritance (PlainMeta is in fact an extension to BasicMeta). Access to a metaobject of an object is given through the function getmetaobject. If the object does not have a metaobject, this is created on the y. You can remove a metaobject from an object with the function restoreobject. If the metaobject was an instance of BasicMeta the reective changes to the object will still exist after this call. However, if the metaobject was an instance of PlainMeta, the changes through reection will disappear when you restore the object (because the changes has not been done directly on the object). However, changes in the object because of its normal use will of course survive. A.1 Reection exception ReectionException(Exception): All new exceptions or error-types introduced by the reection module is handled by this exception class. A.2 Attributes ignored when inspecting IgnoreAttr: Attributes to ignore when inspecting an object or a class. The class has 2 members: inobject is the list of attributes ignored when inspecting an object and inclass is list of attributes ignored when inspecting a class. A.3 Inspect an object inspectobject(o): Inspects the object o. The result is a dictionary with 4 members: 'class' is the class of the object, 'vars' are the attributes in the object (not including the class 7

8 attributes), 'allattr' is all the attributes of the object (not including methods, but including the class attributes) and 'allmethods' is all methods for the object (including the inherited methods). A.4 Inspect a class inspectclass(c): Inspects the class c. The result is a dictionary with 4 members: 'bases' is the base classes (direct parent classes) of the class, 'vars' are the attributes in the class (not including attributes from the base classes), 'allattr' is all the attributes of the class (not including methods, but including the inherited attributes) and 'allmethods' is all methods for the class (including the inherited methods). A.5 Add a method to an object addmethodobject(o, name, function, override=0): Adds a method with the key name and the implementation function to the object o. The rst argument of the function should be the object it self (the self argument). If override is false (default) an exception will occur if a method with the key name exists. A.6 Delete a method from an object delmethodobject(o, name, completely=0): Deletes a method with the key name from object o. A ReectionException exception is raised if the method does not exists. If the completely argument is true (not default) the method will be hidden completely (also inherited methods with this key). A.7 Add a method to a class addmethodclass(c, name, function, override=0): Adds a method with the key name and the implementation function to the class c. The rst argument of the function should be the object it self (the self argument). If override is false (default) an exception will occur if a method with the key name exists. A.8 Delete a method from a class delmethodclass(c, name, completely=0): Deletes a method with the key name from class c. A ReectionException exception is raised if the method does not exists. If the completely argument is true (not default) the method will be hidden completely (also inherited methods with this key). A.9 Add a pre-method to a method addpremethodobject(o, name, function): Adds a pre-method with the implementation function for the method with the key name in the object o. The new method will be inserted rst in the list of pre-methods. 8

9 A.10 Delete pre-methods from a method delpremethodsobject(o, name, function=none): Deletes the pre-methods of the method with the key name in the object o. If function is given, only the given function is deleted. Otherwise all pre-methods are deleted. A.11 Add a post-method to a method addpostmethodobject(o, name, function): Adds a post-method with the implementation function for the method with the key name in the object o. The new method will be appended last to the list of post-methods. A.12 Delete post-methods from a method delpostmethodsobject(o, name, function=none): Deletes the post-methods of the method with the key name in the object o. If function is given, only the given function is deleted. Otherwise all the post-methods are deleted. A.13 Change the class of an object changeclassobject(o, newclass): Change the class of the object o to the class newclass. A.14 The basic metaobject BasicMeta: This is the class for the simplest metaobject. All reection is done in the actual object, which means that the changes through reection are still visible after the object is restored. The creation of a metaobject has an optional argument o which is the object under control of this metaobject. You can create a metaobject without an object, and then later connect the object to the metaobject with the metaobjects settoobject method. An exception will be raised if you try to use this on an object which allready has a metaobject. A.14.1 Connect the metaobject to an object settoobject(self, o): Make this the metaobject for o. A.14.2 Inspect the object inspect(self): Returns the dictionary representing the inspected object. A.14.3 Return a string representing the object repr(self): Returns a string representing the object. A.14.4 Get the value of an attribute getattr(self, key): Gets the attribute key from the object. 9

10 A.14.5 Set the value of an attribute setattr(self, key, value): Sets the attribute key in the object to the given value. A.14.6 Delete an attribute delattr(self, key): Deletes the attribute key in the object. A.14.7 Add a method addmethod(self, name, function, override=0): Adds the method function with the key name to the object. A.14.8 Delete a method delmethod(self, name, completely=0): Deletes the method withe the key name from the object. A.14.9 Add a pre-method addpremethod(self, name, function): Adds the pre-method function to the method with the key name in the object. A Delete pre-methods delpremethods(self, name, function=none): Deletes the pre-methods of the method with the key name or only the pre-method function if it is given. A Add a post-method addpostmethod(self, name, function): Adds the post-method function to the method with the key name in the object. A Delete post-methods delpostmethods(self, name, function=none): Deletes the post-methods of the method with the key name or only the post-method function if it is given. A Change the class changeclass(self, newclass): Change the class of the object to newclass. 10

11 A.15 The plain metaobject PlainMeta(BasicMeta): A metaobject of this class will do all the reection in its own internal datastructures, without inuencing the actual object. All changes through reection will disappear when the object is restored. Normal changes in the object, like the values of attributes, will of course still be there. A.15.1 Connect the metaobject to an object settoobject(self, o): Make this the metaobject for o. A.15.2 Inspect the object inspect(self): Returns a dictionary representing the inspected object. A.15.3 Call the method message(self, msg): Calls a method of the object using the information in msg. A.15.4 Add a method addmethod(self, name, function, override=0): Adds the method function with the key name to the object. A.15.5 Delete a method delmethod(self, name, completely=0): Deletes the method with the key name from the object. A.15.6 Add a pre-method addpremethod(self, name, function): Adds the pre-method function to the method with the key name in the object. A.15.7 Delete pre-methods delpremethods(self, name, function=none): Deletes the pre-methods of the method with the key name or only the pre-method function if it is given. A.15.8 Add a post-method addpostmethod(self, name, function): Adds the post-method function to the method with the key name in the object. 11

12 A.15.9 Delete post-methods delpostmethods(self, name, function=none): Deletes the post-methods of the method with the key name or only the post-method function if it is given. A Change the class changeclass(self, newclass): Change the class of the object to newclass. A.16 Get the metaobject of an object getmetaobject(o, metaclass = None): Returns the metaobject of the object o. If the object doesn't have a metaobject, a new metaobject is created on the y. You can give the class of the new metaobject in the optional metaclass argument. Otherwise a default one is chosen based on the defaultmeta attribute of the object or the implementation of getmetaobject. A.17 Restore an object restoreobject(o): Removes the metaobject from the object o. 12

What is a class? Responding to messages. Short answer 7/19/2017. Code Listing 11.1 First Class. chapter 11. Introduction to Classes

What is a class? Responding to messages. Short answer 7/19/2017. Code Listing 11.1 First Class. chapter 11. Introduction to Classes chapter 11 Code Listing 11.1 First Class Introduction to Classes What is a class? If you have done anything in computer science before, you likely will have heard the term object oriented programming (OOP)

More information

Dangerously Advanced Python

Dangerously Advanced Python Dangerously Advanced Python Mike Verdone for Protospace, Calgary May 2009 http://mike.verdone.ca/ Introspection and Metaprogramming Introspection: Programs that can interrogate their own data structures

More information

Principles of Programming Languages, 2

Principles of Programming Languages, 2 Principles of Programming Languages, 2 Matteo Pradella February 2015 Matteo Pradella Principles of Programming Languages, 2 February 2015 1 / 23 1 Object Oriented Programming (OO) Matteo Pradella Principles

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

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

Shigeru Chiba Michiaki Tatsubori. University of Tsukuba. The Java language already has the ability for reection [2, 4]. java.lang.

Shigeru Chiba Michiaki Tatsubori. University of Tsukuba. The Java language already has the ability for reection [2, 4]. java.lang. A Yet Another java.lang.class Shigeru Chiba Michiaki Tatsubori Institute of Information Science and Electronics University of Tsukuba 1-1-1 Tennodai, Tsukuba, Ibaraki 305-8573, Japan. Phone: +81-298-53-5349

More information

Idioms and Anti-Idioms in Python

Idioms and Anti-Idioms in Python Idioms and Anti-Idioms in Python Release 2.6.3 Guido van Rossum Fred L. Drake, Jr., editor October 06, 2009 Python Software Foundation Email: docs@python.org Contents 1 Language Constructs You Should Not

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

CSE : Python Programming

CSE : Python Programming CSE 399-004: Python Programming Lecture 2: Data, Classes, and Modules January 22, 2007 http://www.seas.upenn.edu/~cse39904/ Administrative things Teaching assistant Brian Summa (bsumma @ seas.upenn.edu)

More information

What is a Class? Short Answer. Responding to Messages. Everything in Python is an Object 11/8/2010

What is a Class? Short Answer. Responding to Messages. Everything in Python is an Object 11/8/2010 The Practice of Computing Using PYTHON William Punch Richard Enbody Chapter 11 Introduction to Classes class Student(object): """Simple Student class.""" def init (self,first='', last='', id=0): # init

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

Context-Oriented Programming with Python

Context-Oriented Programming with Python Context-Oriented Programming with Python Martin v. Löwis Hasso-Plattner-Institut an der Universität Potsdam Agenda Meta-Programming Example: HTTP User-Agent COP Syntax Implicit Layer Activation Django

More information

RbCl: A Reective Object-Oriented Concurrent Language. without a Run-time Kernel. Yuuji Ichisugi, Satoshi Matsuoka, Akinori Yonezawa

RbCl: A Reective Object-Oriented Concurrent Language. without a Run-time Kernel. Yuuji Ichisugi, Satoshi Matsuoka, Akinori Yonezawa RbCl: A Reective Object-Oriented Concurrent Language without a Run-time Kernel Yuuji Ichisugi, Satoshi Matsuoka, Akinori Yonezawa Department of Information Science, The University of Tokyo 3 Abstract We

More information

Data Structures (list, dictionary, tuples, sets, strings)

Data Structures (list, dictionary, tuples, sets, strings) Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access

More information

Beyond Blocks: Python Session #1

Beyond Blocks: Python Session #1 Beyond Blocks: Session #1 CS10 Spring 2013 Thursday, April 30, 2013 Michael Ball Beyond Blocks : : Session #1 by Michael Ball adapted from Glenn Sugden is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike

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

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017 Overview of OOP Dr. Zhang COSC 1436 Summer, 2017 7/18/2017 Review Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in square brackets: l = [1, 2, "a"] (access by index, is mutable

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

Friday, 11 April 14. Advanced methods for creating decorators Graham Dumpleton PyCon US - April 2014

Friday, 11 April 14. Advanced methods for creating decorators Graham Dumpleton PyCon US - April 2014 Advanced methods for creating decorators Graham Dumpleton PyCon US - April 2014 Intermission Rant about the history of this talk and why this topic matters. Python decorator syntax @function_wrapper def

More information

Python 3000 and You. Guido van Rossum PyCon March 14, 2008

Python 3000 and You. Guido van Rossum PyCon March 14, 2008 Python 3000 and You Guido van Rossum PyCon March 14, 2008 Why Py3k Open source needs to move or die Matz (creator of Ruby) To fix early, sticky design mistakes e.g. classic classes, int division, print

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

EXPRESSIONS, STATEMENTS, AND FUNCTIONS 1

EXPRESSIONS, STATEMENTS, AND FUNCTIONS 1 EXPRESSIONS, STATEMENTS, AND FUNCTIONS 1 COMPUTER SCIENCE 61A June 24, 2014 0.1 Warmup What Would Python Do? >>> x = 6 >>> def square(x):... return x * x >>> square(x) >>> max(pow(2, 3), square(-5)) -

More information

a b c d a b c d e 5 e 7

a b c d a b c d e 5 e 7 COMPSCI 230 Homework 9 Due on April 5, 2016 Work on this assignment either alone or in pairs. You may work with different partners on different assignments, but you can only have up to one partner for

More information

Table of Contents EVALUATION COPY

Table of Contents EVALUATION COPY Table of Contents Introduction... 1-2 A Brief History of Python... 1-3 Python Versions... 1-4 Installing Python... 1-5 Environment Variables... 1-6 Executing Python from the Command Line... 1-7 IDLE...

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

Alastair Burt Andreas Eisele Christian Federmann Torsten Marek Ulrich Schäfer. October 6th, Universität des Saarlandes. Introduction to Python

Alastair Burt Andreas Eisele Christian Federmann Torsten Marek Ulrich Schäfer. October 6th, Universität des Saarlandes. Introduction to Python Outline Alastair Burt Andreas Eisele Christian Federmann Torsten Marek Ulrich Schäfer Universität des Saarlandes October 6th, 2009 Outline Outline Today s Topics: 1 More Examples 2 Cool Stuff 3 Text Processing

More information

GIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes

GIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes GIS 4653/5653: Spatial Programming and GIS More Python: Statements, Types, Functions, Modules, Classes Statement Syntax The if-elif-else statement Indentation and and colons are important Parentheses and

More information

Generic Function Parameter and Method Parameter Metaobjects: A Proposed Enhancement to the CLOS Metaobject Protocol. Eric L.

Generic Function Parameter and Method Parameter Metaobjects: A Proposed Enhancement to the CLOS Metaobject Protocol. Eric L. Generic Function Parameter and Method Parameter Metaobjects: A Proposed Enhancement to the CLOS Metaobject Protocol Eric L. Peterson Articial Intelligence Technologies Center MITRE Corporation 1820 Dolley

More information

Rapid Application Development with

Rapid Application Development with Rapid Application Development with Scripting: Higher Level Programming for the 21st Century (IEEE Computer, March 1998) http://home.pacbell.net/ouster/scripting.html python Scripting Languages vs. System

More information

Appendix B Boost.Python

Appendix B Boost.Python Financial Modelling in Python By S. Fletcher & C. Gardner 2009 John Wiley & Sons Ltd Appendix B Boost.Python The Boost.Python library provides a framework for seamlessly wrapping C++ classes, functions

More information

CS 349 / SE 382 Scripting. Professor Michael Terry March 18, 2009

CS 349 / SE 382 Scripting. Professor Michael Terry March 18, 2009 CS 349 / SE 382 Scripting Professor Michael Terry March 18, 2009 Today s Agenda Scripting Jython CS 349 / SE 382 / 2 Announcements Assignment 4 due next Friday! CS 349 / SE 382 / 3 Questions? CS 349 /

More information

Reflective Java and A Reflective Component-Based Transaction Architecture

Reflective Java and A Reflective Component-Based Transaction Architecture Reflective Java and A Reflective Component-Based Transaction Architecture Zhixue Wu APM Ltd., Poseidon House, Castle Park, Cambridge CB3 0RD UK +44 1223 568930 zhixue.wu@citrix.com ABSTRACT In this paper,

More information

Semantic Analysis. Lecture 9. February 7, 2018

Semantic Analysis. Lecture 9. February 7, 2018 Semantic Analysis Lecture 9 February 7, 2018 Midterm 1 Compiler Stages 12 / 14 COOL Programming 10 / 12 Regular Languages 26 / 30 Context-free Languages 17 / 21 Parsing 20 / 23 Extra Credit 4 / 6 Average

More information

Programming Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science Indian Institute of Technology, Madras

Programming Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science Indian Institute of Technology, Madras Programming Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science Indian Institute of Technology, Madras Module 12B Lecture - 41 Brief introduction to C++ Hello, welcome

More information

Software Design and Analysis for Engineers

Software Design and Analysis for Engineers Software Design and Analysis for Engineers by Dr. Lesley Shannon Email: lshannon@ensc.sfu.ca Course Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc251 Simon Fraser University Slide Set: 2 Date:

More information

OBJECT ORIENTED PROGRAMMING 6

OBJECT ORIENTED PROGRAMMING 6 OBJECT ORIENTED PROGRAMMING 6 COMPUTER SCIENCE 61A October 10, 2013 1 Overview This week, you were introduced to the programming paradigm known as Object Oriented Programming. If you ve programmed in a

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

Introduction to Python - Part I CNV Lab

Introduction to Python - Part I CNV Lab Introduction to Python - Part I CNV Lab Paolo Besana 22-26 January 2007 This quick overview of Python is a reduced and altered version of the online tutorial written by Guido Van Rossum (the creator of

More information

Programming Robots with ROS, Morgan Quigley, Brian Gerkey & William D. Smart

Programming Robots with ROS, Morgan Quigley, Brian Gerkey & William D. Smart Programming Robots with ROS, Morgan Quigley, Brian Gerkey & William D. Smart O Reilly December 2015 CHAPTER 23 Using C++ in ROS We chose to use Python for this book for a number of reasons. First, it s

More information

1: Introduction to Object (1)

1: Introduction to Object (1) 1: Introduction to Object (1) 김동원 2003.01.20 Overview (1) The progress of abstraction Smalltalk Class & Object Interface The hidden implementation Reusing the implementation Inheritance: Reusing the interface

More information

Cross-platform daemonization tools.

Cross-platform daemonization tools. Cross-platform daemonization tools. Release 0.1.0 Muterra, Inc Sep 14, 2017 Contents 1 What is Daemoniker? 1 1.1 Installing................................................. 1 1.2 Example usage..............................................

More information

a declaration of class name, and a class docstring

a declaration of class name, and a class docstring Question 1. [10 marks] Implement a class that models a cash register in a store. This cash register will know what the HST tax rate is (charged on all sales, for simplicity), is able to make sales, and

More information

CIS192 Python Programming

CIS192 Python Programming CIS192 Python Programming Iterators, Generators, Exceptions & IO Raymond Yin University of Pennsylvania September 28, 2016 Raymond Yin (University of Pennsylvania) CIS 192 September 28, 2016 1 / 26 Outline

More information

jquery UI Widget Factory

jquery UI Widget Factory jquery UI Widget Factory Scott González jquery UI development lead http://nemikor.com @scott_gonzalez $(λ); The widget factory - What is it? - Why do we need it? - How do we use it? $.widget(); Why we

More information

MITOCW watch?v=flgjisf3l78

MITOCW watch?v=flgjisf3l78 MITOCW watch?v=flgjisf3l78 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality educational resources for free. To

More information

6.001 Notes: Section 1.1

6.001 Notes: Section 1.1 6.001 Notes: Section 1.1 Slide 1.1.1 This first thing we need to do is discuss the focus of 6.001. What is this course all about? This seems quite obvious -- this is a course about computer science. But

More information

6.001 Notes: Section 15.1

6.001 Notes: Section 15.1 6.001 Notes: Section 15.1 Slide 15.1.1 Our goal over the next few lectures is to build an interpreter, which in a very basic sense is the ultimate in programming, since doing so will allow us to define

More information

Be careful when deciding whether to represent data as integers or floats, and be sure that you consider all possible behaviors in computation.

Be careful when deciding whether to represent data as integers or floats, and be sure that you consider all possible behaviors in computation. Table of Contents: 1. Integers and floats 2. for vs. while loops 3. Checking boolean conditions with if/else 4. Docstrings 5. Changing collections while iterating over them 6. Directly Accessing Instance

More information

Taking the Derivative

Taking the Derivative Taking the Derivative Programming II - Elixir Version Johan Montelius Spring Term 2018 Introduction You of course know how to take the derivative of a function, this is something you probably learned already

More information

And Parallelism. Parallelism in Prolog. OR Parallelism

And Parallelism. Parallelism in Prolog. OR Parallelism Parallelism in Prolog And Parallelism One reason that Prolog is of interest to computer scientists is that its search mechanism lends itself to parallel evaluation. In fact, it supports two different kinds

More information

Modules and scoping rules

Modules and scoping rules C H A P T E R 1 1 Modules and scoping rules 11.1 What is a module? 106 11.2 A first module 107 11.3 The import statement 109 11.4 The module search path 110 11.5 Private names in modules 112 11.6 Library

More information

Objects and Classes. Chapter 8

Objects and Classes. Chapter 8 200 Chapter 8 Objects and Classes The style of programming we have seen so far is called procedural programming. This was the first programming paradigm, developed in the 1950 s and 1960 s alongside the

More information

Object Model Comparisons

Object Model Comparisons Object Model Comparisons 1 Languages are designed, just like programs Someone decides what the language is for Someone decides what features it's going to have Can't really understand a language until

More information

COMP1730/COMP6730 Programming for Scientists. Testing and Debugging.

COMP1730/COMP6730 Programming for Scientists. Testing and Debugging. COMP1730/COMP6730 Programming for Scientists Testing and Debugging. Overview * Testing * Debugging * Defensive Programming Overview of testing * There are many different types of testing - load testing,

More information

API Knowledge Coding Guide Version 7.2

API Knowledge Coding Guide Version 7.2 API Knowledge Coding Guide Version 7.2 You will be presented with documentation blocks extracted from API reference documentation (Javadocs and the like). For each block, you will be also presented with

More information

CS61A Notes Week 13: Interpreters

CS61A Notes Week 13: Interpreters CS61A Notes Week 13: Interpreters Read-Eval Loop Unlike Python, the result of evaluating an expression is not automatically printed. Instead, Logo complains if the value of any top-level expression is

More information

OOPP: A reflective component-based middleware

OOPP: A reflective component-based middleware OOPP: A reflective component-based middleware Anders Andersen Λ Department of Computer Science University of Tromsø N-9037 Troms, Norway aa@computer.org Gordon S. Blair y Computing Department Lancaster

More information

In fact, as your program grows, you might imagine it organized by class and superclass, creating a kind of giant tree structure. At the base is the

In fact, as your program grows, you might imagine it organized by class and superclass, creating a kind of giant tree structure. At the base is the 6 Method Lookup and Constant Lookup As we saw in Chapter 5, classes play an important role in Ruby, holding method definitions and constant values, among other things. We also learned how Ruby implements

More information

Python 3000 and You. Guido van Rossum EuroPython July 7, 2008

Python 3000 and You. Guido van Rossum EuroPython July 7, 2008 Python 3000 and You Guido van Rossum EuroPython July 7, 2008 Why Py3k Open source needs to move or die Matz (creator of Ruby) To fix early, sticky design mistakes e.g. classic classes, int division, print

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

Object-Oriented Programming

Object-Oriented Programming 6.081, Spring Semester, 2007 Lecture 3 Notes 1 MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6.081 Introduction to EECS I Spring Semester, 2007 Lecture

More information

QUIZ. How could we disable the automatic creation of copyconstructors

QUIZ. How could we disable the automatic creation of copyconstructors QUIZ How could we disable the automatic creation of copyconstructors pre-c++11? What syntax feature did C++11 introduce to make the disabling clearer and more permanent? Give a code example. Ch. 14: Inheritance

More information

Project 5 - The Meta-Circular Evaluator

Project 5 - The Meta-Circular Evaluator MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6.001 Structure and Interpretation of Computer Programs Fall Semester, 2005 Project 5 - The Meta-Circular

More information

CS61A Lecture 20 Object Oriented Programming: Implementation. Jom Magrotker UC Berkeley EECS July 23, 2012

CS61A Lecture 20 Object Oriented Programming: Implementation. Jom Magrotker UC Berkeley EECS July 23, 2012 CS61A Lecture 20 Object Oriented Programming: Implementation Jom Magrotker UC Berkeley EECS July 23, 2012 COMPUTER SCIENCE IN THE NEWS http://www.theengineer.co.uk/sectors/electronics/news/researchers

More information

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction Lecture 13: Object orientation Object oriented programming Introduction, types of OO languages Key concepts: Encapsulation, Inheritance, Dynamic binding & polymorphism Other design issues Smalltalk OO

More information

Create a Login System in Visual Basic. Creating a login system. Start a new visual basic Windows Forms application project. Call it Login System

Create a Login System in Visual Basic. Creating a login system. Start a new visual basic Windows Forms application project. Call it Login System Creating a login system Start a new visual basic Windows Forms application project Call it Login System Change the form TITLE from Form1 to Login System Add the following to the form Component Text Name

More information

Report. Middleware Proxy: A Request-Driven Messaging Broker For High Volume Data Distribution

Report. Middleware Proxy: A Request-Driven Messaging Broker For High Volume Data Distribution CERN-ACC-2013-0237 Wojciech.Sliwinski@cern.ch Report Middleware Proxy: A Request-Driven Messaging Broker For High Volume Data Distribution W. Sliwinski, I. Yastrebov, A. Dworak CERN, Geneva, Switzerland

More information

MOODLE MANUAL TABLE OF CONTENTS

MOODLE MANUAL TABLE OF CONTENTS 1 MOODLE MANUAL TABLE OF CONTENTS Introduction to Moodle...1 Logging In... 2 Moodle Icons...6 Course Layout and Blocks...8 Changing Your Profile...10 Create new Course...12 Editing Your Course...15 Adding

More information

Functions Structure and Parameters behind the scenes with diagrams!

Functions Structure and Parameters behind the scenes with diagrams! Functions Structure and Parameters behind the scenes with diagrams! Congratulations! You're now in week 2, diving deeper into programming and its essential components. In this case, we will talk about

More information

EDMS. Architecture and Concepts

EDMS. Architecture and Concepts EDMS Engineering Data Management System Architecture and Concepts Hannu Peltonen Helsinki University of Technology Department of Computer Science Laboratory of Information Processing Science Abstract

More information

Object-Oriented Design

Object-Oriented Design Object-Oriented Design Lecture 14: Design Workflow Department of Computer Engineering Sharif University of Technology 1 UP iterations and workflow Workflows Requirements Analysis Phases Inception Elaboration

More information

Microsoft Excel Level 2

Microsoft Excel Level 2 Microsoft Excel Level 2 Table of Contents Chapter 1 Working with Excel Templates... 5 What is a Template?... 5 I. Opening a Template... 5 II. Using a Template... 5 III. Creating a Template... 6 Chapter

More information

Senthil Kumaran S

Senthil Kumaran S Senthil Kumaran S http://www.stylesen.org/ Agenda History Basics Control Flow Functions Modules History What is Python? Python is a general purpose, object-oriented, high level, interpreted language Created

More information

PROGRAMMING FUNDAMENTALS

PROGRAMMING FUNDAMENTALS PROGRAMMING FUNDAMENTALS TESTING, MAIN, GLOBAL VARIABLES João Correia Lopes INESC TEC, FEUP 23 October 2018 FPRO/MIEIC/2018-19 23/10/2018 1 / 24 INTRODUCTION GOALS By the end of this class, the student

More information

ENVIRONMENT MODEL: FUNCTIONS, DATA 18

ENVIRONMENT MODEL: FUNCTIONS, DATA 18 ENVIRONMENT MODEL: FUNCTIONS, DATA 18 COMPUTER SCIENCE 61A Jon Kotker and Tom Magrino July 18, 2012 1 Motivation Yesterday, we introduced the environment model of computation as an alternative to the earlier

More information

Runtime Dynamic Models Documentation Release 1.0

Runtime Dynamic Models Documentation Release 1.0 Runtime Dynamic Models Documentation Release 1.0 Will Hardy October 05, 2016 Contents 1 Defining a dynamic model factory 1 1.1 Django models.............................................. 1 1.2 Django s

More information

Functions CHAPTER 5. FIGURE 1. Concrete syntax for the P 2 subset of Python. (In addition to that of P 1.)

Functions CHAPTER 5. FIGURE 1. Concrete syntax for the P 2 subset of Python. (In addition to that of P 1.) CHAPTER 5 Functions The main ideas in this chapter are: first-class functions: functions are values that can be passed as arguments to other functions, returned from functions, stored in lists and dictionaries,

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

Programming for Engineers in Python

Programming for Engineers in Python Programming for Engineers in Python Lecture 5: Object Oriented Programming Autumn 2011-12 1 Lecture 4 Highlights Tuples, Dictionaries Sorting Lists Modular programming Data analysis: text categorization

More information

Create quick link URLs for a candidate merge Turn off external ID links in candidate profiles... 4

Create quick link URLs for a candidate merge Turn off external ID links in candidate profiles... 4 Credential Manager 1603 March 2016 In this issue Pearson Credential Management is proud to announce Generate quick link URLs for a candidate merge in the upcoming release of Credential Manager 1603, scheduled

More information

QUIZ. How could we disable the automatic creation of copyconstructors

QUIZ. How could we disable the automatic creation of copyconstructors QUIZ How could we disable the automatic creation of copyconstructors pre-c++11? What syntax feature did C++11 introduce to make the disabling clearer and more permanent? Give a code example. QUIZ How

More information

UNIX Tutorial One

UNIX Tutorial One 1.1 Listing files and directories ls (list) When you first login, your current working directory is your home directory. Your home directory has the same name as your user-name, for example, ee91ab, and

More information

The State of Python. and the web. Armin Ronacher

The State of Python. and the web. Armin Ronacher The State of Python and the web Armin Ronacher // @mitsuhiko Who am I Armin Ronacher (@mitsuhiko) Founding Member of the Pocoo Team we're doing Jinja2, Werkzeug, Flask, Pygments, Sphinx and a bunch of

More information

Introduction to Python Part 2

Introduction to Python Part 2 Introduction to Python Part 2 v0.2 Brian Gregor Research Computing Services Information Services & Technology Tutorial Outline Part 2 Functions Tuples and dictionaries Modules numpy and matplotlib modules

More information

User Filter State. Chapter 11. Overview of User Filter State. The PDSAUserFilterState Class

User Filter State. Chapter 11. Overview of User Filter State. The PDSAUserFilterState Class Chapter 11 User Filter State When users visit a search page (or an add, edit and delete page with a set of search filters above the grid), each user will enter search criteria, drill down on a search result

More information

with a Meta-Level Architecture Department of Information Science, The University oftokyo In Proceedings of 7th European Conference on Object-Oriented

with a Meta-Level Architecture Department of Information Science, The University oftokyo In Proceedings of 7th European Conference on Object-Oriented Designing an Extensible Distributed Language with a Meta-Level Architecture Shigeru Chiba Takashi Masuda Department of Information Science, The University oftokyo E-mail: fchiba,masudag@is.s.u-tokyo.ac.jp

More information

Week - 01 Lecture - 04 Downloading and installing Python

Week - 01 Lecture - 04 Downloading and installing Python Programming, Data Structures and Algorithms in Python Prof. Madhavan Mukund Department of Computer Science and Engineering Indian Institute of Technology, Madras Week - 01 Lecture - 04 Downloading and

More information

Overloading. F21SC Industrial Programming: Python: Advanced Language Features. Overloading. Overloading arithmetic operations

Overloading. F21SC Industrial Programming: Python: Advanced Language Features. Overloading. Overloading arithmetic operations F21SC Industrial Programming: Python: Advanced Language Features Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh Semester 1 2016/17 0 No proprietary

More information

COMP 250 Winter generic types, doubly linked lists Jan. 28, 2016

COMP 250 Winter generic types, doubly linked lists Jan. 28, 2016 COMP 250 Winter 2016 5 generic types, doubly linked lists Jan. 28, 2016 Java generics In our discussion of linked lists, we concentrated on how to add or remove a node from the front or back of a list.

More information

Python Object Sharing. Steen Viken Valvåg

Python Object Sharing. Steen Viken Valvåg Python Object Sharing Steen Viken Valvåg December 2002 Abstract Language support for threads was introduced at a late stage in the Python development process. To accomodate that the majority of Python

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

Relationship Manager

Relationship Manager Relationship Manager Graeme Geldenhuys 2009-07-10 In this article we are going to look at the problem surrounding object oriented programming and object relationships. We will look at the traditional way

More information

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity. OOPS Viva Questions 1. What is OOPS? OOPS is abbreviated as Object Oriented Programming system in which programs are considered as a collection of objects. Each object is nothing but an instance of a class.

More information

CIS192 Python Programming

CIS192 Python Programming CIS192 Python Programming Web Servers and Web APIs Raymond Yin University of Pennsylvania November 12, 2015 Raymond Yin (University of Pennsylvania) CIS 192 November 12, 2015 1 / 23 Outline 1 Web Servers

More information

CS61A Lecture 15 Object Oriented Programming, Mutable Data Structures. Jom Magrotker UC Berkeley EECS July 12, 2012

CS61A Lecture 15 Object Oriented Programming, Mutable Data Structures. Jom Magrotker UC Berkeley EECS July 12, 2012 CS61A Lecture 15 Object Oriented Programming, Mutable Data Structures Jom Magrotker UC Berkeley EECS July 12, 2012 COMPUTER SCIENCE IN THE NEWS http://www.iospress.nl/ios_news/music to my eyes device converting

More information

Assignment II: Foundation Calculator

Assignment II: Foundation Calculator Assignment II: Foundation Calculator Objective The goal of this assignment is to extend the CalculatorBrain from last week to allow inputting variables into the expression the user is typing into the calculator.

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

Python Essential Reference, Second Edition - Chapter 5: Control Flow Page 1 of 8

Python Essential Reference, Second Edition - Chapter 5: Control Flow Page 1 of 8 Python Essential Reference, Second Edition - Chapter 5: Control Flow Page 1 of 8 Chapter 5: Control Flow This chapter describes related to the control flow of a program. Topics include conditionals, loops,

More information

A lot of people make repeated mistakes of not calling their functions and getting errors. Make sure you're calling your functions.

A lot of people make repeated mistakes of not calling their functions and getting errors. Make sure you're calling your functions. Handout 2 Functions, Lists, For Loops and Tuples [ ] Functions -- parameters/arguments, "calling" functions, return values, etc. Please make sure you understand this example: def square(x): return x *

More information

CS 61A Discussion 8: Scheme. March 23, 2017

CS 61A Discussion 8: Scheme. March 23, 2017 CS 61A Discussion 8: Scheme March 23, 2017 Announcements Ants is due today. Finish it! Also turn it in! HW 6 is due tomorrow. Finish it! Also turn it in! HW party today from 6:30-8:30p in 247 Cory. Midterm

More information